diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-12-08 13:25:27 -0500 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-12-08 13:25:27 -0500 |
commit | 3998e9509ffb511bb449965f1ca0695e2bec2c7d (patch) | |
tree | dfa802805528a91d6f7c02c03756d3921830c076 /src/4dvecops/transform4d.cpp | |
parent | 9c5976ed413561467d9f73d1f42a2104bfc05195 (diff) |
add specific transform 4d file, with basic helper function
Diffstat (limited to 'src/4dvecops/transform4d.cpp')
-rw-r--r-- | src/4dvecops/transform4d.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/4dvecops/transform4d.cpp b/src/4dvecops/transform4d.cpp new file mode 100644 index 0000000..91f0d8c --- /dev/null +++ b/src/4dvecops/transform4d.cpp @@ -0,0 +1,12 @@ +#include "raytracer/raytracer.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 transformPoint4(glm::vec4 point4, glm::mat4 transformDirectionMatrix, glm::vec4 translationPointVector) { + // do the translation first + point4 -= translationPointVector; + // do the rotation and scaling + point4 = transformDirectionMatrix * point4; + return point4; +}
\ No newline at end of file |