Jump to content
  • Advertisement
Sign in to follow this  
jratcliff63367

D3DXQuaternionRotationYawPitchRoll reference implementation?

This topic is 3754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Unfortunately Microsoft does not provide source code to the D3DX libraries. This can pose a problem at times. The problem I am trying to resolve is that I have pre-existing code which uses the D3DX library method 'D3DXQuaternionRotationYawPitchRoll'. Portions of this code need to be ported to Linux for our servers. The problem I am encountering is that it appears that however Microsoft implemented this function they did it in a non-standard way. There common documented and open-source expressions of this function are as follows: Expression 1: float sinY, cosY, sinP, cosP, sinR, cosR; sinY = sinf(0.5f * yaw); cosY = cosf(0.5f * yaw); sinP = sinf(0.5f * pitch); cosP = cosf(0.5f * pitch); sinR = sinf(0.5f * roll); cosR = cosf(0.5f * roll); x = cosR * sinP * cosY + sinR * cosP * sinY; y = cosR * cosP * sinY - sinR * sinP * cosY; z = sinR * cosP * cosY - cosR * sinP * sinY; w = cosR * cosP * cosY + sinR * sinP * sinY; Expression 2: x = sinf( yaw / 2.0f) * cosf(pitch / 2.0f) * sinf(roll / 2.0f) + cosf(yaw / 2.0f) * sinf(pitch / 2.0f) * cosf(roll / 2.0f); y = sinf( yaw / 2.0f) * cosf(pitch / 2.0f) * cosf(roll / 2.0f) - cosf(yaw / 2.0f) * sinf(pitch / 2.0f) * sinf(roll / 2.0f); z = cosf(yaw / 2.0f) * cosf(pitch / 2.0f) * sinf(roll / 2.0f) - sinf( yaw / 2.0f) * sinf(pitch / 2.0f) * cosf(roll / 2.0f); w = cosf( yaw / 2.0f) * cosf(pitch / 2.0f) * cosf(roll / 2.0f) + sinf(yaw / 2.0f) * sinf(pitch / 2.0f) * sinf(roll / 2.0f); Both of these expressions are identical, they are just formulated slightly differently. The problem is that however D3DXQuaternionRotationYawPitchRoll is implemented in the D3DX libraries, it does *not* produce the same results! Does anyone know what Microsoft did in their implementation so that I can replicate the exact identical results? This has been a blocking item for me for a very long time and it is finally reaching a critical point. Thanks, John

Share this post


Link to post
Share on other sites
Advertisement
I get results from both sets of your formulae and a D3DX call that differ only in the 7th decimal digit.

How close do you want it? :-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!