Calculating rotation relative to a plane/ground

Started by
2 comments, last by oliii 16 years, 6 months ago
Hey everyone, Alright so here is the question I have a plane that is acting as the ground and I also have an airplane now what I need to do is know the rotation of the airplane relative to the ground so that if the plane is upside down and hits the plane it will crash and so on. The way that I am rotating the airplane is with a quaternion and the airplane can rotate around every axis. Just to let you know I am using xna. oh yeah i have tried just keeping the rotations of the quaternion saved to calculate this but that doesn't work because I allow the player to rotate the airplane on every axis. thanks in advance, Doug
Advertisement
This is the exact situations where three-dimensional rotation spanning-sets manifest their true evilness. Assuming that the quaternion is being used to represent the aircraft's orientation about its local origin, then the quaternion coefficients do not uniquely define the situation and all hell breaks loose.

I suggest that you convert, for this calculation only, to a two-dimensional representation such as spherical polar coordinates. This way, your two coordinates may be thrown directly into a bounds-check for the result. Euler angles will not do, as they suffer the same problem as quaternions.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Thanks for the quick response and the useful information. I was wondering if you know of any good resources where I can read up and learn how to implement a spherical polar coordinates system.
Martin Baker admins a great physics site.

http://www.euclideanspace.com/

As for your question directly, It's quite simple. Convert your orientation quaternion into a matrix, take the middle row or column (the 'up' direction), and dot product with the plane normal to see if plane is aligned to the ground. dot product negative, plane upside down. dot product < 0.5, plane is at more that 60 degree angle from the ground (crash).

If you have the orientation of the plane already, then it's 1/2 the job done already.

Everything is better with Metal.

This topic is closed to new replies.

Advertisement