diff options
author | David Doan <daviddoan@Davids-MacBook-Pro-100.local> | 2023-12-08 15:04:43 -0500 |
---|---|---|
committer | David Doan <daviddoan@Davids-MacBook-Pro-100.local> | 2023-12-08 15:04:43 -0500 |
commit | 87be193a27a4d6ab583982e6d22eaccf154fff34 (patch) | |
tree | 4db10fc80f9077db4aab78ebd288b36ef4ca9368 /src/vec4ops/transform4d.cpp | |
parent | a44bcf18656062785c89e8fde25c232431b0d585 (diff) | |
parent | 480c22ce9b50caad259e254d0127e99294b4c6ab (diff) |
merge
Diffstat (limited to 'src/vec4ops/transform4d.cpp')
-rw-r--r-- | src/vec4ops/transform4d.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vec4ops/transform4d.cpp b/src/vec4ops/transform4d.cpp new file mode 100644 index 0000000..5cc51f3 --- /dev/null +++ b/src/vec4ops/transform4d.cpp @@ -0,0 +1,18 @@ +#include "vec4ops.h" + +// this is used to transform a 4d point by a 4d matrix and its associated translation +// this is motivated by the fact that glm does not support 5d matrices, so we cannot define a mat5 to encapsulate both the rotation and translation in one matrix +// therefore, we break the 5d transformation into a 4d rotation and a 4d translation +glm::vec4 Vec4Ops::transformPoint4(glm::vec4 point4, glm::mat4 transformDirectionMatrix, glm::vec4 translationPointVector) { + // do the translation then direction + point4 = transformDirectionMatrix * point4; + point4 += translationPointVector; + return point4; +} + +glm::vec4 Vec4Ops::inverseTransformPoint4(glm::vec4 point4, glm::mat4 inverseTransformDirectionMatrix, glm::vec4 inverseTranslationPointVector) { + // do the direction then translation + point4 += inverseTranslationPointVector; + point4 = inverseTranslationPointVector * point4; + return point4; +}
\ No newline at end of file |