+#else
+ Global::intersectParam[0] = t;
+ Global::intersectParam[1] = u;
+
+ // If the parameters are in range, we have overlap!
+ if ((t >= 0) && (t <= 1.0) && (u >= 0) && (u <= 1.0))
+ Global::numIntersectParams = 1;
+#endif
+}
+
+
+void Geometry::CheckCircleToCircleIntersection(Object * c1, Object * c2)
+{
+ // Set up global vars
+ Global::numIntersectPoints = Global::numIntersectParams = 0;
+
+ // Get the distance between the centers of the circles
+ Vector centerLine(c1->p[0], c2->p[0]);
+ double d = centerLine.Magnitude();
+ double clAngle = centerLine.Angle();
+
+ // If the distance between centers is greater than the sum of the radii or
+ // less than the difference between the radii, there is NO intersection
+ if ((d > (c1->radius[0] + c2->radius[0]))
+ || (d < fabs(c1->radius[0] - c2->radius[0])))
+ return;
+
+ // If the distance between centers is equal to the sum of the radii or
+ // equal to the difference between the radii, the intersection is tangent
+ // to both circles.
+ if ((d == (c1->radius[0] + c2->radius[0]))
+ || (d == fabs(c1->radius[0] - c2->radius[0])))
+ {
+ Global::intersectPoint[0].x = c1->p[0].x + (cos(clAngle) * c1->radius[0]);
+ Global::intersectPoint[0].y = c1->p[0].y + (sin(clAngle) * c1->radius[0]);
+ Global::numIntersectPoints = 1;
+ return;
+ }
+
+ // Use the Law of Cosines to find the angle between the centerline and the
+ // radial line on Circle #1
+ double a = acos(((c1->radius[0] * c1->radius[0]) + (d * d) - (c2->radius[0] * c2->radius[0])) / (2.0 * c1->radius[0] * d));
+
+ // Finally, find the points of intersection by using +/- the angle found
+ // from the centerline's angle
+ Global::intersectPoint[0].x = c1->p[0].x + (cos(clAngle + a) * c1->radius[0]);
+ Global::intersectPoint[0].y = c1->p[0].y + (sin(clAngle + a) * c1->radius[0]);
+ Global::intersectPoint[1].x = c1->p[0].x + (cos(clAngle - a) * c1->radius[0]);
+ Global::intersectPoint[1].y = c1->p[0].y + (sin(clAngle - a) * c1->radius[0]);
+ Global::numIntersectPoints = 2;