summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-02-01 00:27:05 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-02-01 00:27:05 +0000
commite81bc351f7a7550addea94adb9c445adb1c8ed5c (patch)
tree84c36ae8750e87cc52d0581ee4dd292723f36055
parentAdd utilities for mutating, concatenating, creating vectors (diff)
downloadilt-e81bc351f7a7550addea94adb9c445adb1c8ed5c.tar.bz2
ilt-e81bc351f7a7550addea94adb9c445adb1c8ed5c.tar.xz
ilt-e81bc351f7a7550addea94adb9c445adb1c8ed5c.zip
Add helper operator to perform vec3*mat4 and perspective divide
-rw-r--r--lib/maths.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/maths.h b/lib/maths.h
index c651af5..d4bcd16 100644
--- a/lib/maths.h
+++ b/lib/maths.h
@@ -125,6 +125,13 @@ operator||(const glm::vec<L, T, Q> v1, const T v2)
return {v1, v2};
}
+inline glm::vec3
+operator%(const glm::vec3 & p, const glm::mat4 & mutation)
+{
+ const auto p2 = mutation * (p ^ 1);
+ return p2 / p2.w;
+}
+
constexpr inline float
arc_length(const Arc & arc)
{