diff --git a/vector.cpp b/vector.cpp index ee3903aa..0da22239 100644 --- a/vector.cpp +++ b/vector.cpp @@ -46,12 +46,34 @@ vector::operator*= (double rhs) { } +util::vector +util::vector::operator* (const vector &rhs) const { + return { x * rhs.x, y * rhs.y, z * rhs.z }; +} + + +util::vector& +util::vector::operator*= (const vector &rhs) { + x *= rhs.x; + y *= rhs.y; + z *= rhs.z; + + return *this; +} + + vector vector::operator+ (const vector &rhs) const { return { x + rhs.x, y + rhs.y, z + rhs.z }; } +vector +vector::operator- (void) const { + return { -x, -y, -z }; +} + + vector vector::operator- (const vector &rhs) const { return { x - rhs.x, y - rhs.y, z - rhs.z }; } diff --git a/vector.hpp b/vector.hpp index 8cdd7bc3..6a56d0d2 100644 --- a/vector.hpp +++ b/vector.hpp @@ -28,10 +28,13 @@ namespace util { vector operator* (double) const; vector& operator*=(double); + vector operator* (const vector&) const; + vector& operator*=(const vector&); vector operator+ (const vector&) const; vector& operator+=(const vector&); + vector operator- (void) const; vector operator- (const vector&) const; vector& operator-=(const vector&);