Add operator== and operator!= to Vector3

This commit is contained in:
Eryn Wells 2013-09-13 11:09:37 -07:00
parent a5fd16e5b3
commit b631875246
2 changed files with 24 additions and 0 deletions

View file

@ -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 --
*

View file

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