From a8762504c6d05538e1b701092ac7a2900cd8cdd9 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Sat, 13 Dec 2025 17:37:38 -0600 Subject: [PATCH] math/mat4x4: add mat4x4 * vec4 multiplication --- math/mat4x4.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/math/mat4x4.hpp b/math/mat4x4.hpp index bcddf1f..60a9fa2 100644 --- a/math/mat4x4.hpp +++ b/math/mat4x4.hpp @@ -152,6 +152,23 @@ inline constexpr vec<3, T> operator* #undef c } +template +inline constexpr vec<4, T> operator* +( + mat<4, 4, T> const& m, + vec<4, T> const& v +) +{ +#define c(i) ( \ + m[i][0] * v[0] \ + + m[i][1] * v[1] \ + + m[i][2] * v[2] \ + + m[i][3] * v[3]) + + return vec<4, T>(c(0), c(1), c(2), c(3)); +#undef c +} + template inline constexpr mat<4, 4, T> transpose(mat<4, 4, T> const& m) {