]> Shamusworld >> Repos - architektonas/blobdiff - src/vector.cpp
Further progress on Polylines: Polylines can be selected and moved.
[architektonas] / src / vector.cpp
index 8b2dda2a22301372e956b8bad7fcb2da5fd56d37..fbe45ff70f82b9713ff454b4e8eb432407f66069 100644 (file)
 
 #include "vector.h"
 
-#include <math.h>                                                              // For sqrt()
+#include <math.h>                              // For sqrt()
 #include "mathconstants.h"
 
 // Vector implementation
 
-Vector::Vector(double xx/*= 0*/, double yy/*= 0*/, double zz/*= 0*/): x(xx), y(yy), z(zz)
+Vector::Vector(double xx/*= 0*/, double yy/*= 0*/, double zz/*= 0*/): x(xx), y(yy), z(zz), b(0)
 {
 }
 
-Vector::Vector(Vector tail, Vector head): x(head.x - tail.x), y(head.y - tail.y), z(head.z - tail.z)
+Vector::Vector(Vector tail, Vector head): x(head.x - tail.x), y(head.y - tail.y), z(head.z - tail.z), b(0)
 {
 }
 
-Vector::Vector(const Vector &v): x(v.x), y(v.y), z(v.z)
+Vector::Vector(const Vector &v): x(v.x), y(v.y), z(v.z), b(v.b)
 {
 }
 
@@ -43,7 +43,7 @@ void Vector::SetAngleAndLength(double angle, double length)
 
 Vector Vector::operator=(Vector const v)
 {
-       x = v.x, y = v.y, z = v.z;
+       x = v.x, y = v.y, z = v.z, b = v.b;
 
        return *this;
 }
@@ -267,7 +267,7 @@ bool Vector::isZero(double epsilon/*= 1e-6*/)
        return Vector(-v.y, v.x);
 }
 
-/*static*/ double Vector::AngleBetween(Vector a, Vector b)
+/*static*/ double Vector::AngleBetween(Vector a1, Vector a2)
 {
        // This is done using the following formula:
        // (a . b) = ||a|| ||b|| cos(theta)
@@ -276,10 +276,10 @@ bool Vector::isZero(double epsilon/*= 1e-6*/)
        // Also, the vectors a & b have to be non-zero.
        // Also, have to check using an epsilon because acos will not return an
        // exact value if the vectors are orthogonal.
-       if (a.isZero() || b.isZero())
+       if (a1.isZero() || a2.isZero())
                return 0;
 
-       return acos(a.Dot(b) / (a.Magnitude() * b.Magnitude()));
+       return acos(a1.Dot(a2) / (a1.Magnitude() * a2.Magnitude()));
 }
 
 /*static*/ Point Vector::Midpoint(Point p1, Point p2)