aboutsummaryrefslogtreecommitdiff
path: root/src/vec4ops/vec4ops.cpp
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-12-13 00:51:26 -0500
committersotech117 <michael_foiani@brown.edu>2023-12-13 00:51:26 -0500
commitc6f2be2fed772f300c0cdfe59a4a8a2733d15574 (patch)
tree9006395c9d5d80e381cb626fcd0083da83d07fb9 /src/vec4ops/vec4ops.cpp
parentc6fde36de2d02e487d86e3d04393a1b9e1661d97 (diff)
fixing rays directions 4d
Diffstat (limited to 'src/vec4ops/vec4ops.cpp')
-rw-r--r--src/vec4ops/vec4ops.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/vec4ops/vec4ops.cpp b/src/vec4ops/vec4ops.cpp
index 9bd29e8..cf0900a 100644
--- a/src/vec4ops/vec4ops.cpp
+++ b/src/vec4ops/vec4ops.cpp
@@ -23,7 +23,6 @@ glm::vec4 Vec4Ops::cross4(
result[1] = -(u[0] * f) + (u[2] * c) - (u[3] * b);
result[2] = (u[0] * e) - (u[1] * c) + (u[3] * a);
result[3] = -(u[0] * d) + (u[1] * b) - (u[2] * a);
-
return result;
}
@@ -34,23 +33,23 @@ glm::vec4 Vec4Ops::dot4(
}
glm::mat4 Vec4Ops::getViewMatrix4(
- glm::vec4 upVector,
glm::vec4 lookVector,
+ glm::vec4 upVector,
glm::vec4 overVector) {
// start with the e3 basis vector, the normalized look vector
- glm::vec4 e3 = glm::normalize(lookVector);
+ glm::vec4 e3 = glm::normalize(-lookVector);
// calculate e0 basis vector, from the combinatory cross of up and over with e3
glm::vec4 e0 = cross4(upVector, overVector, e3);
e0 = glm::normalize(e0);
- if (glm::distance(e0, glm::vec4{0, 0, 0, 0}) < 0.0001f) {
+ if (glm::isnan(e0[0]) || glm::isnan(e0[1]) || glm::isnan(e0[2]) || glm::isnan(e0[3])) {
throw std::runtime_error("invalid up vector");
}
// calculate e1 basis vector, from the cross of only the over vector
glm::vec4 e1 = cross4(overVector, e3, e0);
e1 = glm::normalize(e1);
- if (glm::distance(e1, glm::vec4{0, 0, 0, 0}) < 0.0001f) {
+ if (glm::isnan(e1[0]) || glm::isnan(e1[1]) || glm::isnan(e1[2]) || glm::isnan(e1[3])) {
throw std::runtime_error("invalid over vector");
}