I have in the background a GIS, which outputs and accepts Lat/Long/Altitude and Heading/Pitch/Bank. I want to have an aircraft moving over the terrain (but not flying, really).
So what I am doing first is to convert Lat/Long/Alt to a position Vector3:
------------------
Pos = new BEPUutilities.Vector3((float)(StaticHelpers.NauticalMileToMeter(Longitude * 60 * Math.Cos(StaticHelpers.DegreeToRadian(-Latitude)))), (float)(StaticHelpers.FeetToMeter(Altitude)), (float)(StaticHelpers.NauticalMileToMeter(-Latitude * 60)));
------------------
The coordinate system is XNA I understand, so I made Longitude = X axis, Altitude = Y axis and Latitude = Z axis. The two conversions seem to be working, I tried out different Lat/Lon/Alt and I got the correct values I expect in the Vector3. And the way back works as well. (I am not even worried about +/- or scale at this point, really)
Next I also have to convert the rotations back and forth. My code to convert into Quaternion is this:
------------------
Rot = BEPUutilities.Quaternion.CreateFromYawPitchRoll((float)DegreeToRadian(-yaw), (float)DegreeToRadian(-pitch), (float)DegreeToRadian(-roll));
------------------
So this should hopefully give me a quaternion where yaw is around the Y axis if it is consistent with the XNA system? The conversion back is working in the same way, and I have confirmed that whatever I am putting into it I can get back out of it with my backwards conversion.
With that being set up, I expected the rotations to work like this:
Heading = Rotation around world Y axis (as Y is Altitude, pointing upwards)
Pitch = Rotation around aircraft X axis (after Heading rotation)
Bank = Rotation around aircraft Z axis (after Heading and Pitch)
This is my rotation code (for testing, the other one I disabled):
PhysicsEntity.AngularVelocity = new Vector3(0, 1, 0);
And my camera is rotating around the pitch axis, which should not be the case.
I have tons of other problems with the other axis, but as soon as I understand this one, I probably can solve the other ones as well.
From my understanding, setting the AngularVelocity like that should rotate the aircraft around the world Y axis, which is pointing upwards, so it should set the heading.
On a sidenote, in my case, the heading should always rotate in world space. So this is not a yawing motion.
If I understand everything correctly, an aircraft with Yaw Pitch Roll = 0 should have its nose at the positive Z axis and its wings level at the X axis, right?
Please! Tell me what is going on, its driving me insane!

SkyFlash