aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/4dvecops/transform4d.cpp16
-rw-r--r--src/4dvecops/vec4ops.h5
2 files changed, 16 insertions, 5 deletions
diff --git a/src/4dvecops/transform4d.cpp b/src/4dvecops/transform4d.cpp
index 91f0d8c..5cc51f3 100644
--- a/src/4dvecops/transform4d.cpp
+++ b/src/4dvecops/transform4d.cpp
@@ -1,12 +1,18 @@
-#include "raytracer/raytracer.h"
+#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 transformPoint4(glm::vec4 point4, glm::mat4 transformDirectionMatrix, glm::vec4 translationPointVector) {
- // do the translation first
- point4 -= translationPointVector;
- // do the rotation and scaling
+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
diff --git a/src/4dvecops/vec4ops.h b/src/4dvecops/vec4ops.h
index 48d9139..09c7605 100644
--- a/src/4dvecops/vec4ops.h
+++ b/src/4dvecops/vec4ops.h
@@ -21,6 +21,11 @@ public:
static glm::mat4 getRotationMatrix4YW(float angleRadians);
static glm::mat4 getRotationMatrix4ZW(float angleRadians);
+
+ glm::vec4 transformPoint4(glm::vec4 point4, glm::mat4 transformDirectionMatrix, glm::vec4 translationPointVector);
+
+ glm::vec4 inverseTransformPoint4(glm::vec4 point4, glm::mat4 inverseTransformDirectionMatrix,
+ glm::vec4 inverseTranslationPointVector);
};
#endif //PROJECTS_RAY_VEC4OPS_H