mirror of
https://github.com/okalachev/flix.git
synced 2025-07-27 17:49:33 +00:00
Fix Vector::angularRatesBetweenVectors return NaNs on opposite vectors
This commit is contained in:
parent
ad6bc02643
commit
be3d2be9d3
@ -80,6 +80,10 @@ public:
|
|||||||
|
|
||||||
static Vector angularRatesBetweenVectors(const Vector& a, const Vector& b) {
|
static Vector angularRatesBetweenVectors(const Vector& a, const Vector& b) {
|
||||||
Vector direction = cross(a, 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();
|
direction.normalize();
|
||||||
float angle = angleBetweenVectors(a, b);
|
float angle = angleBetweenVectors(a, b);
|
||||||
return direction * angle;
|
return direction * angle;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user