summaryrefslogtreecommitdiff
path: root/lib/maths.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-07 13:23:27 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-07 13:23:27 +0000
commit108bf5b2424da06aa2e1735ffd10a2b713834db8 (patch)
treeaf0918a6a266aa7e6ee1d8129df6d5ef9fc4f8ab /lib/maths.h
parentRemove more use of legacy types and unnecessary pointers from selectable inte... (diff)
parentRemove Position3D from RailVehicle (diff)
downloadilt-108bf5b2424da06aa2e1735ffd10a2b713834db8.tar.bz2
ilt-108bf5b2424da06aa2e1735ffd10a2b713834db8.tar.xz
ilt-108bf5b2424da06aa2e1735ffd10a2b713834db8.zip
Merge branch 'template-types'
Diffstat (limited to 'lib/maths.h')
-rw-r--r--lib/maths.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/maths.h b/lib/maths.h
index c1bf61a..b5af9ca 100644
--- a/lib/maths.h
+++ b/lib/maths.h
@@ -68,9 +68,9 @@ 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)
+template<glm::qualifier Q>
+inline constexpr glm::vec<3, int64_t, Q>
+crossProduct(const glm::vec<3, int64_t, Q> a, const glm::vec<3, int64_t, Q> b)
{
return {
(a.y * b.z) - (a.z * b.y),
@@ -79,6 +79,20 @@ crossInt(const glm::vec<3, T, Q> a, const glm::vec<3, T, Q> b)
};
}
+template<std::integral T, glm::qualifier Q>
+inline constexpr glm::vec<3, T, Q>
+crossProduct(const glm::vec<3, T, Q> a, const glm::vec<3, T, Q> b)
+{
+ return crossProduct<int64_t, Q>(a, b);
+}
+
+template<std::floating_point T, glm::qualifier Q>
+inline constexpr glm::vec<3, T, Q>
+crossProduct(const glm::vec<3, T, Q> a, const glm::vec<3, T, Q> b)
+{
+ return glm::cross(a, b);
+}
+
template<typename R = float, typename Ta, typename Tb>
inline constexpr auto
ratio(Ta a, Tb b)