Sign in to follow this  
garrus

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

Recommended Posts

garrus    113

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)

Edited by garrus

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this