# quaternions - coordinate space transformation?

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

## 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 on other sites
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 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 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 on other sites
Quote:
 Original post by Eelcoconjugate 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 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 on other sites
Quote:
 Original post by jykYour 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.