]> Shamusworld >> Repos - architektonas/blobdiff - src/vector.cpp
Added line-to-circle intersection code.
[architektonas] / src / vector.cpp
index a60c1334fd4469897510a350d86c6ccf3d8d37d8..53c6bfef4ab0d49e25c5baf0a18bb56569aa86ac 100644 (file)
@@ -214,7 +214,11 @@ double Vector::Angle(void)
        // quadrant the angle is in... Though, if the y-coordinate of the vector is
        // negative, that means that the angle is in quadrants III - IV.
        double rawAngle = acos(Unit().x);
+#if 0
        double correctedAngle = (y < 0 ? (2.0 * PI) - rawAngle : rawAngle);
+#else
+       double correctedAngle = (y < 0 ? TAU - rawAngle : rawAngle);
+#endif
 
        return correctedAngle;
 }
@@ -243,6 +247,15 @@ bool Vector::isZero(double epsilon/*= 1e-6*/)
 }
 
 
+//
+// Convenience function
+//
+/*static*/ double Vector::Angle(Point p1, Point p2)
+{
+       return Vector(p1, p2).Angle();
+}
+
+
 // Returns the parameter of a point in space to this vector. If the parameter
 // is between 0 and 1, the normal of the vector to the point is on the vector.
 // Note: v1 is the tail, v2 is the head of the line (vector).