Repository navigation
Fix Euler rotation matrix convention in Matrix3f and Matrix4f - #41
Merged
Merged
Conversation
Matrix3f.setEulers had m[1][1] and m[2][1] swapped compared to the standard R=Rh(Y)*Rp(X)*Rr(Z) rotation matrix that both Quaternion and the Vince reference use. Matrix3f.getEulers correspondingly extracted cosr from the wrong element. Matrix4f.setEulers used a different convention (heading about Z, pitch about Y, roll about X) instead of the Y-X-Z convention used by Quaternion. Aligned it to match. Closes #34
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.
Summary
Root cause
Matrix3f.setEulers had two matrix elements transposed, producing the wrong rotation matrix. Matrix4f.setEulers used a different rotation order entirely (heading about Z) versus the Y-X-Z convention used by Quaternion.setEulers (Vince p.201) and Quaternion.getMat3 (Vince p.202). The convention mismatch caused 3x-magnitude errors in Euler round-trips.
Verified numerically against R = Rh(Y) * Rp(X) * Rr(Z) computed from first principles.
Closes #34
Test plan
QuaternionTest.testEulersRoundTrip()passesQuaternionTest.testMatrix3fRoundTrip()passesQuaternionTest.testMatrix4fRoundTrip()passes