X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvector.cpp;h=e9ad51f3427fa06ad918dd7793986369cacdef87;hb=746443089f76c115245d1500b780d7d189b9b2af;hp=da0d4c557aae2fe4e68b5df17d8cf0d4ce5f0ccf;hpb=9f6ad3fe0b9cb30115a5d38e8af3aebed0d70c08;p=architektonas diff --git a/src/vector.cpp b/src/vector.cpp index da0d4c5..e9ad51f 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -25,6 +25,10 @@ Vector::Vector(double xx/*= 0*/, double yy/*= 0*/, double zz/*= 0*/): x(xx), y(y { } +Vector::Vector(Vector head, Vector tail): x(head.x - tail.x), y(head.y - tail.y), z(head.z - tail.z) +{ +} + Vector Vector::operator=(Vector const v) { x = v.x, y = v.y, z = v.z; @@ -169,3 +173,11 @@ double Vector::Dot(Vector v1, Vector v2) { return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); } + +double Vector::Magnitude(Vector v1, Vector v2) +{ + double xx = v1.x - v2.x; + double yy = v1.y - v2.y; + double zz = v1.z - v2.z; + return sqrt(xx * xx + yy * yy + zz * zz); +}