You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m using Quat::slerp to extrapolate rotations, and it works perfectly when the angle is greater than about π / 49.65, in which case the dot product is 0.9994995, suspiciously close to the dot threshold of 0.9995 where Quat::slerp falls back to Quat::lerp. However, when the angle is smaller than that, e.g. π / 60.00, then extrapolation no longer works properly, and the rotation goes slower as the s parameter to Quat::slerp goes further beyond 1.0.
Notice how in the first example, the resulting angle is 2π, i.e. properly extrapolated; whereas in the second example, the resulting angle is not even close to 2π.
I’m not quite sure why the special case for small angles exists; is it merely an optimization? Or is it there to avoid problems with precision? I saw in #57 that the implementation of Quat::slerp was based on that in cgmath. But cgmath falls back to nlerp, not lerp, which might behave differently.
It would be nice to have extrapolation work as expected, like it does for e.g. Vec3::lerp. Do you think that would be acceptable, perhaps as a separate method?
(Or maybe I shouldn’t use quaternions for animations. EDIT: I have since switched to using axis–angle representation for animations and it works better, also because it can handle rotations larger than 180° properly.)
The text was updated successfully, but these errors were encountered:
zopsicle
changed the title
Quat::slerp dot threshold prevents extrapolation when difference in angle is greater than about π / 49.65
Quat::slerp dot threshold prevents extrapolation when difference in angle is smaller than about π / 49.65
Oct 25, 2022
as the s parameter to Quat::slerp goes further beyond 1.0.
It's been a long time since I've thought about any of this, but I don't think it will work if the s value exceeds 1.0. Does it work in cgmath? (and does it work with the older version of cgmath circa #57?)
glam's version of lerp normalizes (or at least it did?) and it is/was/i-thought equivalent to cgmath's nlerp.
I’m using
Quat::slerp
to extrapolate rotations, and it works perfectly when the angle is greater than about π / 49.65, in which case the dot product is 0.9994995, suspiciously close to the dot threshold of 0.9995 whereQuat::slerp
falls back toQuat::lerp
. However, when the angle is smaller than that, e.g. π / 60.00, then extrapolation no longer works properly, and the rotation goes slower as thes
parameter toQuat::slerp
goes further beyond 1.0.Example code:
Notice how in the first example, the resulting angle is 2π, i.e. properly extrapolated; whereas in the second example, the resulting angle is not even close to 2π.
I’m not quite sure why the special case for small angles exists; is it merely an optimization? Or is it there to avoid problems with precision? I saw in #57 that the implementation of
Quat::slerp
was based on that in cgmath. But cgmath falls back tonlerp
, notlerp
, which might behave differently.It would be nice to have extrapolation work as expected, like it does for e.g.
Vec3::lerp
. Do you think that would be acceptable, perhaps as a separate method?(Or maybe I shouldn’t use quaternions for animations. EDIT: I have since switched to using axis–angle representation for animations and it works better, also because it can handle rotations larger than 180° properly.)
The text was updated successfully, but these errors were encountered: