Add vector equality operator

This commit is contained in:
Danny Robson 2011-10-29 15:07:34 +11:00
parent 10b127415a
commit 0946382b71
2 changed files with 10 additions and 0 deletions

View File

@ -109,6 +109,14 @@ vector::operator= (const vector &rhs) {
} }
bool
vector::operator== (const vector &rhs) const {
return almost_equal (x, rhs.x) &&
almost_equal (y, rhs.y) &&
almost_equal (z, rhs.z);
}
double double
vector::magnitude (void) const { vector::magnitude (void) const {
return sqrt (x * x + y * y + z * z); return sqrt (x * x + y * y + z * z);

View File

@ -40,6 +40,8 @@ namespace util {
vector& operator =(const vector &); vector& operator =(const vector &);
bool operator== (const vector &) const;
double magnitude (void) const; double magnitude (void) const;
double magnitude2 (void) const; double magnitude2 (void) const;