#### Archived

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

# special vector rotation

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

## Recommended Posts

i need to rotate a vector according to the mouse movement: i use this vector as a direction vector for the movement and later for things like shooting (rockets etc.). if i move the mouse to the left or right, the vector rotates around the y-axis and if i move the mouse up or down the vector rotates around the x-axis. for this i have two variables xrotation and yrotation. i add the x and y movements from the mouse to that variables. every frame i reset the vector to: x = 0 y = 0 z =-1 and then i rotate it by xrotation around the x-axis and yrotation around the y-axis. this works already, but if i rotate the vector +90 degrees around the y-axis so that it is x = 1 y = 0 z = 0 and then move the mouse up and down, it has no effect on the y coordinate of the vector. i know why, because i now have to rotate the vector around the z-axis to point up and down. but i want to rotate the vector around the x-axis every time to point up and down without looking on the y-rotation. also if i rotate the vector 180 degrees around the y-axis and then point up and down the vector moves the inversed way (if i move the mouse up the y coordinate decreases and if i move the mouse down it increases). i heard about gimbal lock and that i can solve it with quaternions. is my problem gimbal lock or can anybody help me ?

##### Share on other sites
That is not gimble lock, but rather just a confusing control scheme. It is the equivalent of controlling an aircraft with an external view that always points north and controls relative to the view rather than the aircraft. So when the aircraft is headed east/west the up/down movement of the mouse roll the aircraft because you are rotating around the views x-axis which is the aircrafts forward axis. Without any idea of what you are controlling or the viewpoint I can''t suggest a better control scheme. I would suggest adding up and right vectors then using axis angle rotations.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 16
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011524
• ### Who's Online (See full list)

There are no registered users currently online

×