GPSnoopy

09-30-2003, 10:47 PM

AFAIK either using Euler angles rotations or quaternions you still end up doing rotations using the regular world coordinate system.

But, for example, when a plane makes a roll or a pitch it's around its own axis. So that rotations are always relative to its own local system.

I haven't tested yet but it seems to me that the following would lead to the right result:

vector3 XAxis = (1, 0, 0);

vector3 YAxis = (0, 1, 0);

vector3 ZAxis = (0, 0, 1);

vector3 LocalXAxis = XAxis;

matrix4 PitchMatrix = Rotate(Pitch, LocalXAxis);

vector3 LocalYAxis = PitchMatrix * YAxis;

matrix4 RollMatrix = Rotate(Roll, LocalYAxis);

vector3 LocalZAxis = PitchMatrix * RollMatrix * ZAxis;

matrix4 YawnMatrix = Rotate(Yawn, LocalZAxis);

So it would give LocalRotation(Pitch, Roll, Yawn) = PitchMatrix * RollMatrix * YawnMatrix.

Does this seems correct?

If it is, isn't their any other (and preferably more efficient) way of doing this?

But, for example, when a plane makes a roll or a pitch it's around its own axis. So that rotations are always relative to its own local system.

I haven't tested yet but it seems to me that the following would lead to the right result:

vector3 XAxis = (1, 0, 0);

vector3 YAxis = (0, 1, 0);

vector3 ZAxis = (0, 0, 1);

vector3 LocalXAxis = XAxis;

matrix4 PitchMatrix = Rotate(Pitch, LocalXAxis);

vector3 LocalYAxis = PitchMatrix * YAxis;

matrix4 RollMatrix = Rotate(Roll, LocalYAxis);

vector3 LocalZAxis = PitchMatrix * RollMatrix * ZAxis;

matrix4 YawnMatrix = Rotate(Yawn, LocalZAxis);

So it would give LocalRotation(Pitch, Roll, Yawn) = PitchMatrix * RollMatrix * YawnMatrix.

Does this seems correct?

If it is, isn't their any other (and preferably more efficient) way of doing this?