diff --git a/src/basics.cc b/src/basics.cc index 56f0a2e..b0c21da 100644 --- a/src/basics.cc +++ b/src/basics.cc @@ -142,6 +142,27 @@ Vector3::operator-() } +/* + * Vector3::operator== -- + * Vector3::operator!= -- + * + * Compute boolean equality and non-equality of this and the given vectors. + */ +bool +Vector3::operator==(const Vector3 &rhs) + const +{ + return x == rhs.x && y == rhs.y && z == rhs.z; +} + +bool +Vector3::operator!=(const Vector3 &rhs) + const +{ + return !(*this == rhs); +} + + /* * Vector3::length2 -- * diff --git a/src/basics.h b/src/basics.h index cb26e16..c960281 100644 --- a/src/basics.h +++ b/src/basics.h @@ -28,6 +28,9 @@ struct Vector3 Vector3 operator-(const Vector3 &rhs) const; Vector3 operator-() const; + bool operator==(const Vector3 &rhs) const; + bool operator!=(const Vector3 &rhs) const; + float length2() const; float length() const; float dot(const Vector3 &v) const;