Add more vector operators
This commit is contained in:
parent
cdc651cf66
commit
1c73bddf8b
22
vector.cpp
22
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
|
||||||
vector::operator+ (const vector &rhs) const {
|
vector::operator+ (const vector &rhs) const {
|
||||||
return { x + rhs.x, y + rhs.y, z + rhs.z };
|
return { x + rhs.x, y + rhs.y, z + rhs.z };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector
|
||||||
|
vector::operator- (void) const {
|
||||||
|
return { -x, -y, -z };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
vector
|
vector
|
||||||
vector::operator- (const vector &rhs) const
|
vector::operator- (const vector &rhs) const
|
||||||
{ return { x - rhs.x, y - rhs.y, z - rhs.z }; }
|
{ return { x - rhs.x, y - rhs.y, z - rhs.z }; }
|
||||||
|
@ -28,10 +28,13 @@ namespace util {
|
|||||||
|
|
||||||
vector operator* (double) const;
|
vector operator* (double) const;
|
||||||
vector& operator*=(double);
|
vector& operator*=(double);
|
||||||
|
vector operator* (const vector&) const;
|
||||||
|
vector& operator*=(const vector&);
|
||||||
|
|
||||||
vector operator+ (const vector&) const;
|
vector operator+ (const vector&) const;
|
||||||
vector& operator+=(const vector&);
|
vector& operator+=(const vector&);
|
||||||
|
|
||||||
|
vector operator- (void) const;
|
||||||
vector operator- (const vector&) const;
|
vector operator- (const vector&) const;
|
||||||
vector& operator-=(const vector&);
|
vector& operator-=(const vector&);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user