World to Camera Transformation using Quaternions

Started by
1 comment, last by thewhiteaussie 11 years, 3 months ago

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.

Advertisement
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?
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.

This topic is closed to new replies.

Advertisement