]> Shamusworld >> Repos - ttedit/blobdiff - src/vector.cpp
Added preview window to file loading dialog. :-)
[ttedit] / src / vector.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 1ba2064..baa0422
@@ -9,7 +9,7 @@
 // JLH = James L. Hammons <jlhamm@acm.org>
 //
 // Who  When        What
-// ---  ----------  -------------------------------------------------------------
+// ---  ----------  -----------------------------------------------------------
 // JLH  ??/??/2003  Created original implementation
 // JLH  05/14/2004  Separated header from implementation, added operator-
 //                  function
@@ -153,7 +153,7 @@ void vector::zero(const double epsilon/*= 1.0e-6*/)
 // JLH = James L. Hammons <jlhamm@acm.org>
 //
 // WHO  WHEN        WHAT
-// ---  ----------  ------------------------------------------------------------
+// ---  ----------  ----------------------------------------------------------
 // JLH  09/19/2006  Created this file
 // JLH  03/22/2011  Moved implementation of constructor from header to here
 // JLH  04/02/2011  Fixed divide-by-zero bug in Unit(), added Angle() function
@@ -162,11 +162,7 @@ void vector::zero(const double epsilon/*= 1.0e-6*/)
 #include "vector.h"
 
 #include <math.h>                                                              // For sqrt()
-//#include "mathconstants.h"
-
-#define PI 3.14159265358979323846264338327
-#define RADIANS_TO_DEGREES (180.0 / PI)
-#define DEGREES_TO_RADIANS (PI / 180.0)
+#include "mathconstants.h"
 
 
 // Vector implementation
@@ -354,11 +350,11 @@ double Vector::Magnitude(void)
 
 double Vector::Angle(void)
 {
-       // acos returns a value between zero and PI, which means we don't know which
-       // 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.
+       // acos returns a value between zero and PI, which means we don't know
+       // which 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);
-       double correctedAngle = (y < 0 ? (2.0 * PI) - rawAngle : rawAngle);
+       double correctedAngle = (y < 0 ? TAU - rawAngle : rawAngle);
 
        return correctedAngle;
 }