aboutsummaryrefslogtreecommitdiff
path: root/src/vec4ops/transform4d.cpp
blob: 66ca8e3904d6b6abfcd7bcc98178c268791363c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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;
}

glm::vec4 Vec4Ops::transformDir4(glm::vec4 dir4, glm::mat4 transformDirectionMatrix) {
    // do the direction
    dir4 = transformDirectionMatrix * dir4;
    return dir4;
}

glm::vec4 Vec4Ops::inverseTransformDir4(glm::vec4 dir4, glm::mat4 inverseTransformDirectionMatrix) {
    // do the direction
    dir4 = inverseTransformDirectionMatrix * dir4;
    return dir4;
}