Sign in to follow this  
AbsolutDew

How do you get the facing of a D3DXQUATERNION?

Recommended Posts

I thought quaternions fully described orientation in 3d space, but I haven't been able to figure out how to get the direction it's facing. Am I way off here? I see how to transform a vector by a quaternion with D3DXVec3TransformCoord, do I need to keep track of the direction seperately? That would suck =/ Not much of a DirectX question but (if possible) I'd like to confine myself to the D3DX family of math functions for the time being.

Share this post


Link to post
Share on other sites
Quaternions don't face a direction. Quaternion is just a construct, a set of numbers. It can be interpreted as a rotation description. But I've yet to see it interpreted as a "direction".

Quaternion is an extention of angle in 2D - to 3D. You don't ask of a direction of an angle => you don't ask of a direction of a quaternion. A quaternions doesn't describe orientation - it describes a rotation of some base orientation. In order to ask of a final orientation (after being rotated) you've got to answer the question -> "what's your base orientation?".


I figure you're asking of the outcome of vector (0,0,1) transformed by a quaternion. Is that right?

Share this post


Link to post
Share on other sites
Quote:
Original post by deffer
Quaternions don't face a direction. Quaternion is just a construct, a set of numbers. It can be interpreted as a rotation description. But I've yet to see it interpreted as a "direction".

Quaternion is an extention of angle in 2D - to 3D. You don't ask of a direction of an angle => you don't ask of a direction of a quaternion. A quaternions doesn't describe orientation - it describes a rotation of some base orientation. In order to ask of a final orientation (after being rotated) you've got to answer the question -> "what's your base orientation?".


I figure you're asking of the outcome of vector (0,0,1) transformed by a quaternion. Is that right?


I guess I didn't really know what I was asking. So a quaternion can fully describe orientation if I combine it with a base orientation like (0,0,1)? Why would you pick that particular one?

Oh, that would be the up vector normally passed to 3DXMatrixLookAtLH!

Share this post


Link to post
Share on other sites
generally when you want to translate something "forward" you do it in the positive z direction. That's entirely arbitrary and dependant on the coordinate system you're using.

Quaternion * Vector effectively rotates the vector according to the quaternion, so if positive z is "forward" then multiplying (0, 0, 1) by your quaternion will effectively give you the direction it's facing

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this