From d3e72911975df2782130f3f930352f5884563ad3 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Tue, 19 Dec 2023 04:58:20 +0300 Subject: [PATCH] Guard for angleBetweenVectors function to ensure it doesn't return NaN --- flix/vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flix/vector.h b/flix/vector.h index 5b2df3f..02779af 100644 --- a/flix/vector.h +++ b/flix/vector.h @@ -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)