- double discriminant = ((c->radius * c->radius) * (dr * dr)) - (determinant * determinant);
-
- if (discriminant < 0)
- return false;
-
-
-
- return true;
-#else
-/*
-I'm thinking a better approach to this might be as follows:
-
--- Get the distance of the circle's center from the line segment. If it's
- > the radius, it doesn't intersect.
--- If the parameter is off the line segment, check distance to endpoints. (Not sure
- how to proceed from here, it's different than the following.)
- [Actually, you can use the following for all of it. You only know if you have
- an intersection at the last step, which is OK.]
--- If the radius == distance, we have a tangent line.
--- If radius > distance, use Pythagorus to find the length on either side of the
- normal to the spots where the hypotenuse (== radius' length) contact the line.
--- Use those points to find the parameter on the line segment; if they're not on
- the line segment, no intersection.
-*/
- double t = ParameterOfLineAndPoint(l->position, l->endpoint, c->position);
-//small problem here: it clamps the result to the line segment. NOT what we want
-//here! !!! FIX !!! [DONE]
- Vector p = l->GetPointAtParameter(t);
- double distance = Vector::Magnitude(c->position, p);
-
- // If the center of the circle is farther from the line than the radius, fail.
- if (distance > c->radius)
- return 0;
-
- // Now we have to check for intersection points.
- // Tangent case: (needs to return something)
- if ((distance == c->radius) && (t >= 0.0) && (t <= 1.0))
- {
- // Need to set tp & up to something... !!! FIX !!!
- if (tp)
- *tp = t;
-
- if (up)
- *up = Vector(c->position, p).Angle();