#### Archived

This topic is now archived and is closed to further replies.

# Quaternion Translation..

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

## Recommended Posts

I have asked this question before... But does anyone know how to do translations using quaternions? Please help! Thanks! [edited by - zealouselixir on August 27, 2002 6:00:20 PM]

##### Share on other sites
Unit Quaternions are ONLY for rotations. A point and a quaternion specify an exact location and facing in 3D space!

##### Share on other sites
Do translations and scaling using matrices, and rotations using quaternions.

##### Share on other sites
Chromebender...

So how do you combine the two? Or can you? I have done the rotations using quaternions, scaling using the gl scaling function, but no translation...at least not yet.

##### Share on other sites
bah yet AGAIN a post to this board failed to be submitted. here goes:

Evidently you know how to do rotations by keeping a rotation quaternion, converting it to a matrix and multiplying the modelview matrix by the rotation matrix.

To do a translation, simply multiply the matrix or vector by a translation matrix composed of:

1 0 0 0
0 1 0 0
0 0 1 0
x y z 1

where x,y and z are the distance to translate the previous transformation matrix

if you wanted to handle scaling yourself, a scaling matrix consisting of

sx 0 0 0
0 sy 0 0
0 0 sz 0
0 0 0 1

should do the trick.

So if you wanted to rotate the camera say PI/2 radians around the z axis, you would convert this angle, axis pair to a quaternion, then convert the quaternion to the rotationMatrix. Then to translate the camera, create your transformation matrix for whatever x,y and z you want. Next retrieve the modelview matrix and multiple it by the translation matrix then by the rotation matrix (the reverse order of the way you want the operations performed).

##### Share on other sites
Another tip: Keep track of your camera (or object)''s up, right and direction vectors. This makes it easy to transform movement relative to the camera or object frame into world coordinates. Previously I had a problem where my camera controls were locked onto the x, y and z axes regardless of where the camera was pointing, which made camera control a real pain and in some cases impossible. Now it flies around in true 6-d.o.f. descent style

##### Share on other sites
Thanks for the reply! I will put this information to good use!

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011314
• ### Who's Online (See full list)

There are no registered users currently online

×