summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-12-02 12:23:52 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-12-02 12:23:52 +0000
commit0a5d23ce263551bab3759e4ac65ecb6cfebdc892 (patch)
tree0b5d6d9a1ff47e5d59d3e6de0f83349c084ade15 /lib
parentRestore some trees (diff)
downloadilt-0a5d23ce263551bab3759e4ac65ecb6cfebdc892.tar.bz2
ilt-0a5d23ce263551bab3759e4ac65ecb6cfebdc892.tar.xz
ilt-0a5d23ce263551bab3759e4ac65ecb6cfebdc892.zip
Add crossInt - cross product for integer vectors
Diffstat (limited to 'lib')
-rw-r--r--lib/maths.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/maths.h b/lib/maths.h
index 67b2a15..cf369a7 100644
--- a/lib/maths.h
+++ b/lib/maths.h
@@ -67,6 +67,17 @@ sq(T v)
return v * v;
}
+template<std::integral T, glm::qualifier Q>
+inline constexpr glm::vec<3, T, Q>
+crossInt(const glm::vec<3, T, Q> a, const glm::vec<3, T, Q> 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),
+ };
+}
+
template<typename R = float, typename Ta, typename Tb>
inline constexpr auto
ratio(Ta a, Tb b)