View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# 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.

2 replies to this topic

### #1thewhiteaussie  Members

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.

### #2Álvaro  Members

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?

### #3thewhiteaussie  Members

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.