X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgeometry.cpp;h=b67c64e30e6211d8cd9dafefbd1204671101f02b;hb=ea7712f342020baf61cf33ba98b12140da6aecf7;hp=11e633f380aef100a282cda4eeb5bf52410f34e7;hpb=4a979ddae8aa6b3556f24e8b961f7787c4b40cbe;p=architektonas diff --git a/src/geometry.cpp b/src/geometry.cpp index 11e633f..b67c64e 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -90,7 +90,6 @@ Point Geometry::MirrorPointAroundLine(Point point, Point tail, Point head) // Point Geometry::RotatePointAroundPoint(Point point, Point rotationPoint, double angle) { -// Vector v = Vector(point, rotationPoint); Vector v = Vector(rotationPoint, point); double px = (v.x * cos(angle)) - (v.y * sin(angle)); double py = (v.x * sin(angle)) + (v.y * cos(angle)); @@ -422,6 +421,17 @@ void Geometry::FindAnglesForSides(double s1, double s2, double s3, double * a1, // Use law of sines to find 2nd & 3rd angles // sin A / a = sin B / b // sin B = (sin A / a) * b +// B = arcsin( sin A * (b / a)) +// ??? ==> B = A * arcsin(b / a) +/* +Well, look here: +sin B = sin A * (b / a) +sin B / sin A = b / a +arcsin( sin B / sin A ) = arcsin( b / a ) + +hmm... dunno... +*/ + double angle2 = asin(s2 * (sin(angle1) / s1)); double angle3 = asin(s3 * (sin(angle1) / s1)); @@ -435,3 +445,17 @@ void Geometry::FindAnglesForSides(double s1, double s2, double s3, double * a1, *a3 = angle3; } + +Point Geometry::GetPointForParameter(Object * obj, double t) +{ + if (obj->type == OTLine) + { + // Translate line vector to the origin, then add the scaled vector to + // initial point of the line. + Vector v = obj->p[1] - obj->p[0]; + return obj->p[0] + (v * t); + } + + return Point(0, 0); +} +