This should be very simple, but I cannot seem to figure it out. Here is what I want to do:
Imagine an airplane sitting on the xy plane pointing in the y direction.
I adjust the airplane’s roll using setR(90).
Now the airplane is still pointing in the y direction, but it is sitting on the yz plane (it’s left wing is pointing up in the positive z direction, and it’s right wing down in the negative z direction).
Now I gradually increase the pitch of the airplane. What I want to happen is for it to rotate around the z axis, as you would expect a plane to do. What it actually does it roates around the x axis, so that the nose of the plane starts to move in the positive Z direction.
I tried adjusing the pitch and the heading according to the roll like so:
self.airplane.setP(self.airplane.getP() + someconstant * cos(self.airplane.getR())
self.airplane.setH(self.airplane.getH() + someconstant * sin(self.airplane.getR())
This works to a degree. When the plane is rolled to a factor of 90 degress it works just fine. If it is rolled to 45 degrees however, it rotates crazily.
I am sure this is really simple and I have been hacking away at it for a while now but I just can’t figure it out. Any help is really appreciated.