Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quaternion to euler bug #2073

Merged
merged 1 commit into from
Apr 15, 2024
Merged

Conversation

cptbtptpbcptdtptp
Copy link
Collaborator

@cptbtptpbcptdtptp cptbtptpbcptdtptp commented Apr 10, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

The derivation process:

  1. Use YXZ Order and expand matrix elements:https://github.com/mrdoob/three.js/blob/ce756225c802ff24cc27a1f615cc9bf420023ae8/src/math/Euler.js#L134
  2. Convert normalized version to non-normalized version :http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/

@cptbtptpbcptdtptp cptbtptpbcptdtptp added bug Something isn't working math Math library labels Apr 10, 2024
@cptbtptpbcptdtptp cptbtptpbcptdtptp self-assigned this Apr 10, 2024
@cptbtptpbcptdtptp
Copy link
Collaborator Author

Referenced ThreeJS processing of converting Quaternion to Euler:
https://github.com/mrdoob/three.js/blob/ce756225c802ff24cc27a1f615cc9bf420023ae8/src/math/Euler.js#L200

				this._z = Math.asin( clamp( m21, - 1, 1 ) );

				if ( Math.abs( m21 ) < 0.9999999 ) {

					this._x = Math.atan2( - m23, m22 );
					this._y = Math.atan2( - m31, m11 );

				} else {

					this._x = 0;
					this._y = Math.atan2( m13, m33 );

				}

Combined with non-normalized Quaternion:

http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/

@GuoLei1990 GuoLei1990 merged commit 165d7ab into galacean:main Apr 15, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working math Math library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants