DefenestrationDay
DefenestrationDay

Reputation: 3830

Rotating quaternion which is in another quaternion's frame?

I have a camera attached to an aircraft.
Rotation 0,0,0 is aircraft flying North, flat and level.
Camera 0,0,0 is pointing straight forward (through the nose).

When the plane yaws (changes it's heading to 270° West) and goes into a 45° dive, the Euler angles for yaw, pitch and roll are (-270, 45, 0)

At this point, the camera is experiencing the same angles (-270, 45, 0).
Now, though, the camera operator raises the camera viewpoint by 90°, and pans right 90°.
My intuition tells me that the camera should now be pointing (0, 0, 45).
NB I'm not too worried about the signs of rotation, atm

I can convert both sets of angles into Quaternions to simplify rotation, but I don't know how to rotate the camera's movement relative to the aircraft attitude. I have to rotate the rotation, but from the earth frame of reference.

How do I rotate a quaternion with respect to another's current 3D rotation?

var absoloutePlatform = Quaternion.RotationYawPitchRoll((float)ToRadians(yaw), (float)ToRadians(pitch), (float)ToRadians(roll));
var relativeSensor = Quaternion.RotationYawPitchRoll((float)ToRadians(yaw2), (float)ToRadians(pitch2), (float)ToRadians(roll2));

var absoluteQuaterion = [[ some calculation! ]]

var absoluteSensorAngles = absoluteQuaterion.GetYawPitchRoll();

Upvotes: 0

Views: 514

Answers (1)

DefenestrationDay
DefenestrationDay

Reputation: 3830

This all stemmed from an unclear understanding of which 'standard' to use when converting quaternions to Euler.

I convert my platform/aircraft (world) rotation from euler into a quaternion.
Then convert my relative sensor angles (from platform reference) into a quaternion.

I multiply them together

var resultQ = platformQ * sensorQ;

Then convert the result back to Euler using zyx rotation order.

This gives the rotation of the sensor in world-frame.
Maybe this is standard in aviation - I don't know.
But the short answer is yes, to rotate a quaternion with reference to another: you multiply them together.

Upvotes: 0

Related Questions