Skip to content

Commit

Permalink
Guard for angleBetweenVectors function to ensure it doesn't return NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
okalachev committed Dec 19, 2023
1 parent fcd695f commit d3e7291
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion flix/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Vector : public Printable

static float angleBetweenVectors(const Vector& a, const Vector& b)
{
return acos(dot(a, b) / (a.norm() * b.norm()));
return acos(constrain(dot(a, b) / (a.norm() * b.norm()), -1, 1));
}

static Vector angularRatesBetweenVectors(const Vector& u, const Vector& v)
Expand Down

0 comments on commit d3e7291

Please sign in to comment.