Add cross product operation to Vector3

This commit is contained in:
Eryn Wells 2013-09-22 08:37:58 -07:00
parent a41817217a
commit 5d14a63c37
2 changed files with 14 additions and 0 deletions

View file

@ -205,6 +205,19 @@ Vector3::dot(const Vector3 &v)
}
/*
* Vector3::cross --
*
* Compute and return the cross product of this and the given vectors.
*/
Vector3
Vector3::cross(const Vector3 &v)
const
{
return Vector3(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
}
/*
* Vector3::normalize --
*

View file

@ -34,6 +34,7 @@ struct Vector3
float length2() const;
float length() const;
float dot(const Vector3 &v) const;
Vector3 cross(const Vector3 &v) const;
Vector3 &normalize();