How to orient an aircraft with earth

Started by
6 comments, last by NexusOne 18 years, 9 months ago
Hi all, I have a 3d aircraft which I want to move along a sphere surface (earth). My problem is how to align/orient (which is the right word?) the aircraft according to the sphere surface. I have rotated the aircraft to point to the direction (horizontal direction) it moves, then I translate it to its position. But the orientation of the aircraft doesn't conform with the earth spherical surface. I know the aircraft should be rotated further before being translated to its position. How the rotation is performed to orient the aircraft according to the sphere surface? Thanks very much.
Advertisement
I can't really understand what you're asking, but it sounds like you might trying to get the plane so it flies parallel to the ground? Notice that the vector from the center of the sphere to your airplane is normal to the surface of the sphere, no matter where your plane is. That normal should be the direction that the top of your plane faces (imagine the bounding box around your plane model - you want to align the top face's normal with the normal you found).
--------------Trans2D - 2D library for C# / Managed DirectX
Yes, that's what I mean. I want to make my aircraft flies parallel to the ground.
So how to align my aircraft normal with the normal of the sphere surface? What kind of rotation should I make?
If your planet has radius R and its center is at (0,0,0), then if the plane is located at location (x,y,z), the "up" normal at that location will be (x,y,z)/sqrt(x2+y2+z2).
Yes, I know how to calculate the surface normal.
My question is: how to rotate my aircraft so that my aircraft up vector is aligned with that normal?
Suppose the surface normal is (x, y, z), and the aircraft's up vector is (0, 1, 0), how to rotate the aircraft so that its up vector becomes (x, y, z)?
The axis of rotation is the cross product of the current up vector and the desired up vector. The angle, is the angle between the two vectors.
I see. Hmmm... why didn't I think about that before?

Thanks a lot Sneftel.
Just a quick comment, the surface normal = the vector from the center of the earth to the plane, so you don't need to calculate it at all
Graphics make the game! 8-)

This topic is closed to new replies.

Advertisement