# Calculating new angles for aircraft rotation?

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

## Recommended Posts

LOL i just want to make model fly, but i cant calculate properly 2 angles :<

i have defined 3 angles roll pitch and yaw

imopi = pi / 180.0f

(please note that i use) opengl for rendering

glRotatef(PHYSIC_MODEL->yaw_angle,0.0,1.0,0.0); // YAW
glRotatef(PHYSIC_MODEL->pitch_angle,1.0,0.0,0.0); // PITCH
glRotatef(PHYSIC_MODEL->roll_angle,0.0,0.0,1.0); // ROLL
[/quote]

so when i want to go 'up' with my aircraft i use this formula

pitch_angle = pitch_angle + sin((roll_angle+90.0f)*imopi)*3.0f;

yaw_angle = yaw_angle - cos((roll_angle+90.0f)*imopi)*3.0f;

and i end with this:

[media]
[/media]

As you can see when roll angle is -360, -270, -180, -90, 0, 90, 180, 270, 360, everything rotates correctly but when its not i got this:

[media]
[/media]

it shouldn't spin like that

well i realize that when yaw angle is between -180 and 180 or pitch angle is between -90 and 90 this formula is true:

pitch_angle = pitch_angle + sin((roll_angle+90.0f)*imopi)*3.0f; yaw_angle = yaw_angle - cos((roll_angle+90.0f)*imopi)*3.0f;

otherwise everything rotates in opposite direction etc. but it is a problem with sign i can make a function like if sin(angle) < 0 then bleble ble else ble

but i cant imagine further calculations :C can anyone help me, if understand this post :F

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

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

• Total Topics
633718
• Total Posts
3013517
×