Skip to content
Snippets Groups Projects
Commit 3990358c authored by Tobias Schmidt's avatar Tobias Schmidt
Browse files

fixed bug in OrthogonalVector for colinear vectors

parent 5b68fd0c
Branches
Tags 1.2.0
No related merge requests found
...@@ -142,16 +142,16 @@ Mat3 EulerTransformation(Real theta, Real phi, Real xi) ...@@ -142,16 +142,16 @@ Mat3 EulerTransformation(Real theta, Real phi, Real xi)
} }
Vec3 OrthogonalVector(const Vec3& vec) { Vec3 OrthogonalVector(const Vec3& vec) {
if (vec[0] < vec[1]) { if (std::abs(vec[0]) < std::abs(vec[1])) {
if (vec[0] < vec[2]) if (std::abs(vec[0]) < std::abs(vec[2]))
return Normalize(Cross(vec, Vec3(1, 0, 0)+vec)); return Normalize(Cross(vec, Vec3(1, 0, 0)+vec));
else else
return Normalize(Cross(vec, Vec3(0, 0, 1)+vec)); return Normalize(Cross(vec, Vec3(0, 0, 1)+vec));
} else { } else {
if (vec[1] < vec[2]) if (std::abs(vec[1]) < std::abs(vec[2]))
return Normalize(Cross(vec, Vec3(0, 1, 0)+vec)); return Normalize(Cross(vec, Vec3(0, 1, 0)+vec));
else else
return Normalize(Cross(vec, Vec3(0, 0, 2)+vec)); return Normalize(Cross(vec, Vec3(0, 0, 1)+vec));
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment