#### Archived

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

# Rotating the view matrix

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

## Recommended Posts

I was just wondering about this... A lot of people speak of trouble with their lookat and up vectors when looking straight up or down, since these two vectors can''t be parallel to each other... I''m assuming that these people recalculate the view matrix every time the pos, lookat or up vector changes. Wouldn''t it be much easier to just set an initial view matrix to a position of (0,0,0), the lookat vector to (0,0,1) (forward) and the up vector to (0,1,0) (up), and then just multiply that matrix with the required rotation/translation matrices? That way, your two vectors are alway perpendicular, and you''d never have to worry about epsilons and looking straight up and such. Also, it would appear more efficient to multiply a matrix with two other matrices than to call D3DXMatrixLookAtLH... Or is there a better way?

##### Share on other sites
Gimbal lock != (up==direction)

Usual way is to simply take the dot product between the **approximate** up vector and the direction vector - if the angle is less than a threshold, swap the components of the up vector - simple.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
633715
• Total Posts
3013495
×