aboutsummaryrefslogtreecommitdiff
path: root/src/vec4ops/rotations4d.cpp
diff options
context:
space:
mode:
authorFate Bussey <lafayette_bussey@brown.edu>2023-12-13 19:41:38 -0500
committerFate Bussey <lafayette_bussey@brown.edu>2023-12-13 19:41:38 -0500
commit015884f1bfe701871b3227fc69598d5d83ab4f5b (patch)
tree30efd18d33a0e3dff4bb67b54f113c5f1527059e /src/vec4ops/rotations4d.cpp
parent5de0f3b6de57aa0cdc6b1aa7efc57836a99ee59a (diff)
parent6e27cd596611758bf82f58cff25ad6310bb5ad6e (diff)
new cyl
Diffstat (limited to 'src/vec4ops/rotations4d.cpp')
-rw-r--r--src/vec4ops/rotations4d.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/vec4ops/rotations4d.cpp b/src/vec4ops/rotations4d.cpp
index 37997de..1ff43a7 100644
--- a/src/vec4ops/rotations4d.cpp
+++ b/src/vec4ops/rotations4d.cpp
@@ -72,3 +72,46 @@ glm::mat4 Vec4Ops::getRotationMatrix4ZW(
result[1][1] = 1;
return result;
}
+
+glm::mat4 Vec4Ops::getRotationMatrix4(
+ std::vector<float> anglesRadians)
+{
+ // make the identity
+ glm::mat4 result = glm::mat4(0.f);
+ result[0][0] = 1.f;
+ result[1][1] = 1.f;
+ result[2][2] = 1.f;
+ result[3][3] = 1.f;
+
+ // apply the rotations, starting with the last angle, which corresponds to ZW
+ if (anglesRadians.size() != 6) {
+ throw std::runtime_error("invalid rotation angle array");
+ }
+ for (int i = 5; i >= 0; i--) {
+ switch (i) {
+ case 0:
+ result *= getRotationMatrix4XY(anglesRadians[i]) * result;
+ break;
+ case 1:
+ result *= getRotationMatrix4ZX(anglesRadians[i]) * result;
+ break;
+ case 2:
+ result *= getRotationMatrix4YZ(anglesRadians[i]) * result;
+ break;
+ case 3:
+ result *= getRotationMatrix4XW(anglesRadians[i]) * result;
+ break;
+ case 4:
+ result *= getRotationMatrix4YW(anglesRadians[i]) * result;
+ break;
+ case 5:
+ result *= getRotationMatrix4ZW(anglesRadians[i]) * result;
+ break;
+ default:
+ throw std::runtime_error("invalid rotation matrix");
+ }
+ }
+
+ return result;
+}
+