general quaternion question -- please help :D

Started by
3 comments, last by lazE 19 years, 5 months ago
If I want to simulate my camera using quaternions I know how to get the rotation that needs to be applied to the scene. My problem is that I can't see how to get the *translation* that I need to apply to the scene. My camera has two quats for rotating (one around x and one around y) but, I'm not exactly sure how to extract the information I need. Thanks in advance!
"We are what we repeatedly do. Excellence, therefore, is not an act, but a habit."-Aristotle
Advertisement
Generally speaking, you should only need one quat to represent the complete orientation (not one for X, one for Y, and even one for Z).

As for translation, you'll need to store that seperately, as a 3-vector. Quaternions usually represent orientation alone, and not translation.
Well basically the way my camera works so far is that when it updates it takes the pitch and yaw angles which get changed via keyboard input and creates two rotations (two quaternions) about the x and y axes. I then multiply those two rotations together and use that resultant quaternion to get a matrix for opengl to multiply into MODELVIEW.


My problem now I guess is I dont really see how to store the translations of my camera. I need to multiply the x, y, and z components of the vector I use to store the translation by some combination of sin and cos of some angles. Are those angles just my pitch and yaw?

Thanks!
"We are what we repeatedly do. Excellence, therefore, is not an act, but a habit."-Aristotle
I'm not sure if this is the question you're asking, but if you have a quaternion that represents your camera's orientation, you can convert the quaternion into a 3x3 matrix. The rows (or columns) of that matrix will be your side, up and forward vectors (which is which depends on your convention). Then, you can use these vectors to move forward and backward, up and down, and strafe.
Yeah I finally got that figured out -- thanks tho.


My current question is this:

My camera as of now acts as a first person camera. Ideally all rotations would occur around some object in my scene and all translations would be relative to the object. I sort of know in my head how this is done but, I can't quite figure out how to implement it. I am thinking that instead of rotating the camera arbitrary x, y and z axes I need to rotate it about the x, y and z axes of the object. I would also need to offet the camera's position by the objects. Like I said tho, I am not sure how to do this...

Any advice?

if posting my code would be help then let me know.

Thanks!
"We are what we repeatedly do. Excellence, therefore, is not an act, but a habit."-Aristotle

This topic is closed to new replies.

Advertisement