X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fvector.cpp;h=53c6bfef4ab0d49e25c5baf0a18bb56569aa86ac;hb=0fcc2d879e1e0ca17eeaceae2159f5143a06586f;hp=a60c1334fd4469897510a350d86c6ccf3d8d37d8;hpb=6c1279871f6bb86bc59e2561b6a7f74ab081f71e;p=architektonas diff --git a/src/vector.cpp b/src/vector.cpp index a60c133..53c6bfe 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -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).