Quaternion Slerp honors closest distance.#90
Merged
dmitshur merged 2 commits intogo-gl:masterfrom Apr 7, 2023
nitrix:fix/quat-slerp-closest
Merged
Quaternion Slerp honors closest distance.#90dmitshur merged 2 commits intogo-gl:masterfrom nitrix:fix/quat-slerp-closest
dmitshur merged 2 commits intogo-gl:masterfrom
nitrix:fix/quat-slerp-closest
Conversation
dmitshur
approved these changes
Apr 4, 2023
Gofmt gets rid of it. (But avoid making further changes that gofmt makes by now, those are best done as a separate change.)
liuhaozhan
added a commit
to liuhaozhan/mathgl
that referenced
this pull request
Jan 31, 2024
Fix the quaternion spherical linear interpolation to make it choose the shortest linear path, which is the intended behavior in graphical animations. GitHub-Pull-Request: go-gl/mathgl#90
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
This is a fix to the quaternion spherical linear interpolation to make it choose the shortest linear path which is the intended behavior in graphical animations.
https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_007_Animations.md#linear
https://github.com/recp/cglm/blob/master/include/cglm/quat.h#L701-L704
You'll find that my changes are in the same spirit as them. Added a test too.
This is a very well known problem. Wikipedia documents it here in detail:
https://en.wikipedia.org/wiki/Slerp#Quaternion_Slerp
However, because the covering is double (q and −q map to the same rotation), the rotation path may turn either the "short way" (less than 180°) or the "long way" (more than 180°). Long paths can be prevented by negating one end if the dot product, cos Ω, is negative, thus ensuring that −90° ≤ Ω ≤ 90°.I ran into this corner case using mathgl, my fork will stay up until the changes can get upstream:
https://github.com/nitrix/mathgl/tree/fix/quat-slerp-closest
Cheers,
Alex.