[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Strange PCB warning



Sorry, forgot to scale atan2 result:
diff --git a/src/find.c b/src/find.c
index b24512a..62f5df0 100644
--- a/src/find.c
+++ b/src/find.c
@@ -1327,6 +1327,24 @@ PVTouchesLine (LineTypePtr line)
   return (False);
 }

+static int
+radius_crosses_arc (float x, float y, ArcTypePtr arc)
+{
+  float alpha = atan2 (y - arc->Y, x - arc->X) * 180 / M_PI, start, delta;
+
+  start = (float) fmod (arc->StartAngle, 360);
+  delta = arc->Delta;
+  if (alpha < 0)
+    alpha += 360;
+  if (start < 0)
+    start += 360;
+  if (delta < 0)
+    {
+      start += delta;
+      delta = -delta;
+    }
+  return (start < alpha && start + delta > alpha);
+}
 /* ---------------------------------------------------------------------------
  * check if two arcs intersect
  * first we check for circle intersections,
@@ -1424,7 +1442,9 @@ ArcArcIntersect (ArcTypePtr Arc1, ArcTypePtr Arc2)
       && x + dy >= Arc2->BoundingBox.X1
       && x + dy <= Arc2->BoundingBox.X2
       && y - dx >= Arc2->BoundingBox.Y1 && y - dx <= Arc2->BoundingBox.Y2)
-    return (True);
+    if (radius_crosses_arc (x + dy, y - dx, Arc1)
+	&& radius_crosses_arc (x + dy, y - dx, Arc2))
+      return (True);

   if (x - dy >= Arc1->BoundingBox.X1
       && x - dy <= Arc1->BoundingBox.X2
@@ -1433,7 +1453,9 @@ ArcArcIntersect (ArcTypePtr Arc1, ArcTypePtr Arc2)
       && x - dy >= Arc2->BoundingBox.X1
       && x - dy <= Arc2->BoundingBox.X2
       && y + dx >= Arc2->BoundingBox.Y1 && y + dx <= Arc2->BoundingBox.Y2)
-    return (True);
+    if (radius_crosses_arc (x - dy, y + dx, Arc1)
+	&& radius_crosses_arc (x - dy, y + dx, Arc2))
+      return (True);

   /* try the end points in case the ends don't actually pierce the
outer radii */
   box = GetArcEnds (Arc1);


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user