mirror of
https://github.com/okalachev/flix.git
synced 2025-08-17 17:16:10 +00:00
Fix Vector::angularRatesBetweenVectors return NaNs on opposite vectors
This commit is contained in:
@@ -80,6 +80,10 @@ public:
|
||||
|
||||
static Vector angularRatesBetweenVectors(const Vector& a, const Vector& b) {
|
||||
Vector direction = cross(a, b);
|
||||
if (direction.zero()) {
|
||||
// vectors are opposite, return any perpendicular vector
|
||||
return cross(a, Vector(1, 0, 0));
|
||||
}
|
||||
direction.normalize();
|
||||
float angle = angleBetweenVectors(a, b);
|
||||
return direction * angle;
|
||||
|
Reference in New Issue
Block a user