Guard for angleBetweenVectors function to ensure it doesn't return NaN

This commit is contained in:
Oleg Kalachev 2023-12-19 04:58:20 +03:00
parent fcd695fdd7
commit d3e7291197

View File

@ -79,7 +79,7 @@ public:
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)