X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgeometry.cpp;h=4cd229f76da7967d10811ed3ff803a0d46427e92;hb=0e8f4edf80206248f0ad87a966d69d9ec9da3d2f;hp=b9158974ec97d902d4ff2e936a2cc4b43e469082;hpb=0fcc2d879e1e0ca17eeaceae2159f5143a06586f;p=architektonas diff --git a/src/geometry.cpp b/src/geometry.cpp index b915897..4cd229f 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -255,14 +255,12 @@ void Geometry::CheckLineToCircleIntersection(Object * l, Object * c) // Radius is the hypotenuse, so we have to use c² = a² + b² => a² = c² - b² double perpendicularLength = sqrt((c->radius[0] * c->radius[0]) - (distance * distance)); - // Now, find the points using the length, then check to see if they are on - // the line segment + // Now, find the intersection points using the length... Vector lineUnit = Vector(l->p[0], l->p[1]).Unit(); Point i1 = p + (lineUnit * perpendicularLength); Point i2 = p - (lineUnit * perpendicularLength); - // Now we have our intersection points, next we need to see if they are on - // the line segment... + // Next we need to see if they are on the line segment... double u = ParameterOfLineAndPoint(l->p[0], l->p[1], i1); double v = ParameterOfLineAndPoint(l->p[0], l->p[1], i2); @@ -342,3 +340,22 @@ Point Geometry::GetPointForParameter(Object * obj, double t) return Point(0, 0); } + +Point Geometry::Midpoint(Line * line) +{ + return Point((line->p[0].x + line->p[1].x) / 2.0, + (line->p[0].y + line->p[1].y) / 2.0); +} + + +/* +How to find the tangent of a point off a circle: + + • Calculate the midpoint on the point and the center of the circle + • Get the length of the line segment from the and the center divided by two + • Use that length to construct a circle with the point at the center and the + radius equal to that length + • The intersection of the two circles are the tangent points + +*/ +