Add more vector operators

This commit is contained in:
Danny Robson 2011-10-24 15:17:15 +11:00
parent cdc651cf66
commit 1c73bddf8b
2 changed files with 25 additions and 0 deletions

View File

@ -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 }; }

View File

@ -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&);