Jump to content

  • Log In with Google      Sign In   
  • Create Account


World to Camera Transformation using Quaternions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 thewhiteaussie   Members   -  Reputation: 157

Like
0Likes
Like

Posted 12 January 2013 - 02:14 AM

I have a question regarding quaternions and rotations.

 

Let the quaternion q(w, x, y, z) represent the orientation of a camera in world space. I use a UVN camera system where u = right vector, v = up vector and n = forward vector. With zero rotation the camera aligns with the world basis vectors (x, y, z) like so:

 

u aligns with +x

v aligns with +z

n aligns with +y

 

My question is how do I construct a quaternion that rotates objects from the RH coordinate system of the world space to a LH coordinate system with the following alignments:

 

u aligns with +x

v aligns with +y

n aligns with +z

 

Previously I've use the matrix

 

[ ux   vx   nx ]

[ uy   vy   ny ]

[ uz   vz   nz ]

 

however want to switch to a completely quaternion based system.

 

I suspect I'll need q-1. This rotates objects into camera space, preserving handedness. To switch alignments I suspect I'll need to swap terms in the quaternion.

 

Thanks.



Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 11709

Like
2Likes
Like

Posted 12 January 2013 - 04:46 AM

Quaternions can't represent arbitrary linear transformations in 3D: Only rotations. Rotations preserve orientation, and you are trying to represent a transformation that does not preserve orientation, so you won't be able to do it with a quaternion.

Can't you just swap v and n at the end?

#3 thewhiteaussie   Members   -  Reputation: 157

Like
0Likes
Like

Posted 12 January 2013 - 01:59 PM

Yes you're right! Also it seems like more work to use Quaternions for the final World to Camera transform. I might just stick with matrices.

Edited by thewhiteaussie, 12 January 2013 - 02:00 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS