#### Archived

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

# Quaternion Look at

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

## Recommended Posts

Hey guys, If I use a vector and a quaternion and to store the position and the orientation of my camera object, what is the quickly and best way to calculates a look-at matrix to be used as the view transform in Direct3D? Should I calculate the amount of angle change and rotate the quaternion? Should I convert the quaternion into something else, such as Euler angles or Axis angle, and work from there? Many thanks in advance. Kinny Wong

##### Share on other sites
This is a bit of a hack and prolly not the best way to do things but. . .

Take a starting point that is defined in terms relative to your camera. This starting point represents the look direction of the camera, assuming that an identity quarternion is used.

For example, if the camera is at (9,0,0) and you want it to look down the x-axis, the absolute look at would be (10,0,0) while the relative would be (1,0,0)

In other words, this pt, the look at pt, represents what you are looking at before the camera is rotated. This pt defines what happens if you don''t rotate the camera.

Then, apply the quaternion to the relative pt to rotate the camera. You will actually have to have 2 of these pts -- one that is the up vector, the other that is the look at vector.

Then, apply D3DXMatrixLookAtLH to your camera, the up vector and the look at vector. (you will have to convert the relative look at point to absolute values.)

This is of course assuming that the quarternion is defined relative to the camera, not the world origin.

Hope that makes some kind of sense.

1. 1
2. 2
Rutin
18
3. 3
khawk
15
4. 4
A4L
14
5. 5

• 9
• 13
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633744
• Total Posts
3013663
×