X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvector.cpp;fp=src%2Fvector.cpp;h=fbe45ff70f82b9713ff454b4e8eb432407f66069;hb=10cf4c797bed05831e976068b7504908279dc997;hp=8b2dda2a22301372e956b8bad7fcb2da5fd56d37;hpb=3c890e51a9763ffcee49e15753453a7da248272b;p=architektonas diff --git a/src/vector.cpp b/src/vector.cpp index 8b2dda2..fbe45ff 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -16,20 +16,20 @@ #include "vector.h" -#include // For sqrt() +#include // 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)