diff --git a/vector.hpp b/vector.hpp index 72c511ed..bfeb6398 100644 --- a/vector.hpp +++ b/vector.hpp @@ -41,6 +41,11 @@ namespace util { vector<3,T> cross (vector<3,T>, vector<3,T>); + template + constexpr + T + cross (vector<2,T>, vector<2,T>); + // polar/cartesian conversions; assumes (mag, angle) form. template vector<2,T> polar_to_cartesian (vector<2,T>); template vector<2,T> cartesian_to_polar (vector<2,T>); diff --git a/vector.ipp b/vector.ipp index 83e8fab3..5d2add75 100644 --- a/vector.ipp +++ b/vector.ipp @@ -48,6 +48,16 @@ util::cross (util::vector<3,T> a, util::vector<3,T> b) } +//----------------------------------------------------------------------------- +template +constexpr +T +util::cross (util::vector<2,T> a, util::vector<2,T> b) +{ + return a[0] * b[1] - a[1] * b[0]; +} + + /////////////////////////////////////////////////////////////////////////////// template constexpr