I’m trying to model the turning of an airplane, specifically banking. So, I want a pitching motion to change the actual pitch and yaw of the airplane based on the level of roll. For example, if the plane has not rolled, pitching it will turn it directly up, but if there is some degree of roll, the plane will turn somewhat up and somewhat to the side.
Right now I’m using a matrix transformation to rotate the model, and the order I’m using makes pitch and yaw independent of roll – so, I need to figure out how roll will affect the pitch and yaw when the plane banks.
Here is what I have tried:
if (keys["arrowleft"]) {
plane.roll -= 0.1;
}
if (keys["arrowright"]) {
plane.roll += 0.1;
}
if (keys["arrowup"]) {
plane.pitch -= 0.1*Math.cos(plane.roll);
plane.yaw -= 0.1*Math.sin(plane.roll);
}
if (keys["arrowdown"]) {
plane.pitch -= 0.1*Math.cos(plane.roll);
plane.yaw -= 0.1*Math.sin(plane.roll);
}
In other words, is there any way to convert a pitching motion while rolling (given current orientation) to proper Euler angles with an elementary formula? Or do I need to use a different matrix transformation?