# Orientation

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

## Recommended Posts

how to move the model in direction of rotation thanks. thanks a lot

##### Share on other sites
I found this code in one of my old project, I hope you can do something with it.

 float MoveX = float(2*sin((CameraAngle-90)*PI/180)); float MoveZ = float(2*cos((CameraAngle-90)*PI/180)); CameraPosX -= MoveX; CameraLookAtX -= MoveX; CameraPosZ += MoveZ; CameraLookAtZ += MoveZ; 

CameraAngle is a number from 0 to 360. This is the number that you have to change when rotating.

##### Share on other sites

how to move the model in direction of rotation thanks. thanks a lot

A "direction of rotation" in the sense you're asking for doesn't exist. Instead, you want to rotate a direction vector (the one that defines the movement direction of the unrotated model) and use the result as direction of movement. Scale the rotated vector to consider the speed and elapsed time and add it to the position of the model's frame.

E.g. using the local z axis vector [ 0 0 1 0 ][sup]t[/sup] as standard movement direction of the model, the matrix vector product
R * [ 0 0 1 0 ][sup]t[/sup] == R[sub]z[/sub]
effectively extracts the 3rd column vector from the rotation matrix as rotated direction of movement. Its length is 1. Using s as speed and dt as the elapsed time give you
s * dt * R[sub]z[/sub]
as motion vector.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 30
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631408
• Total Posts
2999922
×