rustgd / cgmath

A linear algebra and mathematics library for computer graphics.
https://docs.rs/cgmath
Apache License 2.0
1.12k stars 155 forks source link

Fixed opposite quaternion slerp bug #515

Closed hayashi-stl closed 4 years ago

hayashi-stl commented 4 years ago

Fixes #498. And oops, the same rustfmt collateral

hayashi-stl commented 4 years ago

Not sure why the check failed. q and r are Quaternion<f64>, so q.slerp(r, 0.25) is a Quaternion<f64>, and thus q.slerp(r, 0.25).dot(q) is a <Quaternion<f64> as VectorSpace>::Scalar, which is f64. 0.5f64.sqrt() is quite obviously a f64. So there is no f32 to be found. EDIT: This is no longer relevant

aloucks commented 4 years ago

All you need to do is check if the dot product is negative. If it is negative, negate the quaternion and recompute the dot product again.

EDIT: Nevermind - that's whats happening here.