diff --git a/vector.cpp b/vector.cpp index 29f025ab..c913d483 100644 --- a/vector.cpp +++ b/vector.cpp @@ -85,23 +85,6 @@ template util::vector2f util::to_euler (util::vector3f); template util::vector2d util::to_euler (util::vector3d); -/////////////////////////////////////////////////////////////////////////////// -template -vector<3,T> -util::cross (vector<3,T> a, - vector<3,T> b) -{ - return util::vector<3,T> { - a.y * b.z - a.z * b.y, - a.z * b.x - a.x * b.z, - a.x * b.y - a.y * b.x - }; -} - -template vector3f util::cross(vector3f, vector3f); -template vector3d util::cross(vector3d, vector3d); - - //----------------------------------------------------------------------------- template vector<3,T> diff --git a/vector.hpp b/vector.hpp index 5f27091d..e6c44274 100644 --- a/vector.hpp +++ b/vector.hpp @@ -36,11 +36,15 @@ namespace util { void sanity (void) const; }; + template + constexpr + vector<3,T> + cross (vector<3,T>, vector<3,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>); - template vector<3,T> cross (vector<3,T>, vector<3,T>); template vector<3,T> spherical_to_cartesian (vector<3,T>); template vector<3,T> cartesian_to_spherical (vector<3,T>); diff --git a/vector.ipp b/vector.ipp index ddd3be75..6e4750fe 100644 --- a/vector.ipp +++ b/vector.ipp @@ -32,3 +32,17 @@ util::vector::homog (void) const static_assert (D > S, "reducing size loses data"); return (*this).template redim (0.f); } + + +/////////////////////////////////////////////////////////////////////////////// +template +constexpr +util::vector<3,T> +util::cross (util::vector<3,T> a, util::vector<3,T> b) +{ + return { + a.y * b.z - a.z * b.y, + a.z * b.x - a.x * b.z, + a.x * b.y - a.y * b.x + }; +}