diff --git a/include/blt/math/vectors.h b/include/blt/math/vectors.h index a20f90c..a2fc0c0 100644 --- a/include/blt/math/vectors.h +++ b/include/blt/math/vectors.h @@ -133,6 +133,14 @@ namespace blt { dot += left[i] * right[i]; return dot; } + + static inline vec cross(const vec& left, const vec& right) { + // cross is only defined on vectors of size 3. 2D could be implemented, which is a TODO + static_assert(size == 3); + return {left.y() * right.z() - left.z() * right.y(), + left.z() * right.x() - left.x() * right.z(), + left.x() * right.y() - left.y() * right.x()}; + } }; template