diff --git a/src/basics.cc b/src/basics.cc index 63ffd5c..8dd91d4 100644 --- a/src/basics.cc +++ b/src/basics.cc @@ -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 -- * diff --git a/src/basics.h b/src/basics.h index 2ec9a27..ab6b16a 100644 --- a/src/basics.h +++ b/src/basics.h @@ -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();