vec3: add cross product

This commit is contained in:
Zack Buhman 2023-07-23 06:19:13 +00:00
parent 60f3a9d344
commit bc7e9f8a3d
2 changed files with 9 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#pragma once
#include <utility>
#include "vec4.hpp"
template <int R, int C, typename T>
struct mat;

View File

@ -147,3 +147,11 @@ inline constexpr T length(vec<3, T> const& v)
{
return sqrt(dot(v, v));
}
template<typename T>
inline constexpr vec<3, T> cross(vec<3, T> const& x, vec<3, T> const& y)
{
return vec<3, T>(x.y * y.z - y.y * x.z,
x.z * y.x - y.z * x.x,
x.x * y.y - y.x * x.y);
}