]> Shamusworld >> Repos - architektonas/blobdiff - src/geometry.cpp
Fixes for the Layer widget.
[architektonas] / src / geometry.cpp
index 11e633f380aef100a282cda4eeb5bf52410f34e7..b67c64e30e6211d8cd9dafefbd1204671101f02b 100644 (file)
@@ -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);
+}
+