Hi there I am developing an with Bullet physics. I need to reset at some point two axial plains of the rotations of a vehicle so that it is only facing the yaw direction they were headed in. Unfortunately DirectX, Bullet and Boost(to my understanding the word Eular did not come up in a search of quaternions .h file!) did not see it in anyones interest to gift people with the power to translate from a quaternion to Eular XYZ rotations. While I am a programmer and could spend 24 hours plus wrapping the problem myself I have a life and other code to crack on with so cannot get hung up on building my own conversion method as this is a one off need. The fact that the capacity to do this already as a built in functionality of anyones quaternion wrappers seems ludacrous to down right dysfunctional!
Can anyone point me in the direction of a free for commercial use library which will convert quaternion.xyzw to eular.xyz angles of rotation? or a function I can take? I am still livid that I cannot decompose a quaternion to a human readable format without reinventing (or finding a library that has invented) the wheel!
Thanks
EnlightenedOne
Quaternion to Eular
Err.. Probably cause his name is spelled Euler... Anyways, this thread may have what you're looking for.
Generally, a quaternion-to-Euler conversion will reduce to converting the quaternion to a matrix, and then extracting the Euler angles from the matrix. (You can extract the angles directly from the quaternion, but you'll perform most of an implicit quaternion-to-matrix conversion in the process, so IMO it's generally best just to go the matrix route.)
The CML includes code for converting between matrices or quaternions and Euler angles using any axis order (repeating or non-repeating). The code isn't entirely transparent due to its genericity, but you could probably adapt it to your needs.
The thread linked to earlier might contain an answer as well (I didn't look). Also, the math code at geometrictools.com includes code for converting between matrices and Euler angles using various axis orders. A search for 'matrix to Euler' would probably turn up some additional references. (Again, you can convert the quaternion to a matrix, and then extract the Euler angles from the matrix.)
Having said all that, I'll go ahead and mention that in some cases at least, working directly with Euler angles isn't always the best way to solve the alignment problem you mention. (One alternative, for example, is to apply a corrective rotation that aligns the object's 'up' axis with the world 'up' axis.)
The CML includes code for converting between matrices or quaternions and Euler angles using any axis order (repeating or non-repeating). The code isn't entirely transparent due to its genericity, but you could probably adapt it to your needs.
The thread linked to earlier might contain an answer as well (I didn't look). Also, the math code at geometrictools.com includes code for converting between matrices and Euler angles using various axis orders. A search for 'matrix to Euler' would probably turn up some additional references. (Again, you can convert the quaternion to a matrix, and then extract the Euler angles from the matrix.)
Having said all that, I'll go ahead and mention that in some cases at least, working directly with Euler angles isn't always the best way to solve the alignment problem you mention. (One alternative, for example, is to apply a corrective rotation that aligns the object's 'up' axis with the world 'up' axis.)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement