diff --git a/vector.cpp b/vector.cpp index 0da22239..049a7433 100644 --- a/vector.cpp +++ b/vector.cpp @@ -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 vector::magnitude (void) const { return sqrt (x * x + y * y + z * z); diff --git a/vector.hpp b/vector.hpp index 6a56d0d2..b61fce2b 100644 --- a/vector.hpp +++ b/vector.hpp @@ -40,6 +40,8 @@ namespace util { vector& operator =(const vector &); + bool operator== (const vector &) const; + double magnitude (void) const; double magnitude2 (void) const;