Jump to content
  • Advertisement
Sign in to follow this  
wjp

quaternions - coordinate space transformation?

This topic is 4830 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

Hi, so I'm progressing in my understanding of 3d matters (I'm a newbe), but I still have mountains to climb! Ok so this is my problem, if any of you can help its much appecriated: - I have an object that is described in a coordinated space that is Y+ve out of screen Z+ve up and x+ve right. (left handed system I think) - I have a quaternion that describes the rotation of the object in that space. I apply roatations to this quaternion and when drawing the object I apply it to the points of the object. - I have another quaternion that describes the rotation need to draw the object in my screen/view space. This screen/view space is in a right hand coordinate system, with Z +ve coming out of the screen x +ve right and y -ve up the screen. So what I need to do is multiply the 2 quaternions together and apply to the object to draw the object in my screen space with the good rotation (I think). However how on earth do I convert the object space quaternion into the screen space coordinate system? (The reason for all this messing about is to use some existing code that I really don't want to rewrite. Plus this is good knowledge to have). Thanks

Share this post


Link to post
Share on other sites
Advertisement
Quote:
This screen/view space is in a right hand coordinate system, with Z +ve coming out of the screen x +ve right and y -ve up the screen.
+z out, +x right, -y up...isn't that left-handed?

Share this post


Link to post
Share on other sites
conjugate your cameraviewquat, and then just multiply them.

it depends a bit on how the rest of your stuff works, but in general this should work.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Quote:
This screen/view space is in a right hand coordinate system, with Z +ve coming out of the screen x +ve right and y -ve up the screen.
+z out, +x right, -y up...isn't that left-handed?


My mistake I meant +z out, +x right, +y up

Share this post


Link to post
Share on other sites
Quote:
Original post by Eelco
conjugate your cameraviewquat, and then just multiply them.

it depends a bit on how the rest of your stuff works, but in general this should work.


Hi thanks for the reply. I just tried this and in fact it reverses the rotation. A conjugate is:


quaternion conjugate(quaternion quat)
{
quat.x = -quat.x;
quat.y = -quat.y;
quat.z = -quat.z;
return quat;
}


right?

If fact this still has the same behaviour - it just reverse the object rotation. What is wrong is that the object quat. is rotating around the y axis, but when I multiple this with the screen quat. it still rotates the object around the (new) Z axis. I want it to be rotating it around the y axis.
Any other ideas?

thanks.

Share this post


Link to post
Share on other sites
Your conjugate function looks correct (if a little inefficient). Here are a couple of other questions:

How are you applying the quaternion to the object vertices? qpq*? Or are you converting it to a matrix?

Are you translating the object and/or the camera? Or just rotating?

Is the camera quaternion defined in reference to the left-handed or right-handed system?

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Your conjugate function looks correct (if a little inefficient). Here are a couple of other questions:

How are you applying the quaternion to the object vertices? qpq*? Or are you converting it to a matrix?

Are you translating the object and/or the camera? Or just rotating?

Is the camera quaternion defined in reference to the left-handed or right-handed system?


Hi,
Ok I solved the problem by side-stepping it! - I change the object rotation to match the orientation/corrdinate system I wanted (the screen/view). However I think this is a bit of a cheat. So to answer you questions:
1) I convert to a matrix and apply.
2) The object is getting translated into the camera/screen with the quaternion.
3) The camera is right-handed.

Thanks everyone for your thoughts on this - I'm learning lots here.
cheers.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!