Advertisement

rotation around left,up vector messed up (C++,openGL)

Started by February 17, 2013 07:12 PM
-1 comments, last by garrus 12 years ago

Hello.

I am implementing rotation around the up,left vectors of an object in the following way, which for some reason works only individually.
That is, i can rotate perfectly fine around up but after that, if i try rotation around left everything gets messed up.

Same if i rotate around left vector,and then try rotating around up.

Could you tell me if the following general method is correct?

vectors up,left,forward, float arrays with x,y,z components.

For example, if i want to rotate at an angle ANG, around UP (turn left/right).

1. I get the angles of the UP vector from XZ plane and the YZ plane.

Rotating the UP with these angles around the proper axes would align it with the Z axis.

2. I perform these rotations to all the vectors except UP.

3. I perfom the desired rotation with ANG, around Z.

4. I perform the opposite rotations in (2) (again,all vectors but UP),so only the desired rotation "remains".

I could just use glRotate to visualize the rotations, but i want the forward,etc vectors as information to where the object is looking at.

Thanks in advance.

(this forum looks awesome smile.png)

This topic is closed to new replies.

Advertisement