Asked by Silas Waxter
on 17 Aug 2019

If quaternions represent an orientation in space, there is an axis between any two orientations and an angle between them. I'm looking for the procedure to find that angle.

Answer by James Tursa
on 17 Aug 2019

Edited by James Tursa
on 17 Aug 2019

Accepted Answer

For example purposes I am using the coordinate frames as ECI and BODY

Q1 = quaternion from ECI->BODY1

Q2 = quaternion from ECI->BODY2

Then perform the following calculation

Q12 = conj(Q1) * Q2 % <- quaternion conjugate and quaternion multiply

Q12 = quaternion from BODY1->BODY2

There may be MATLAB functions to do the conjugate and multiply, but I don't know at the moment. The conjugate of Q1 is simply [Q(1),-Q(2:4)] of course assuming the scalar is the first element.

If we assume the scalar is the first element of the quaternion, matching the MATLAB quaternion functions convention, then you have

Q12(1) = cos(angle/2)

and

Q12(2:4) = sin(angle/2) * e

where e is the unit axis of rotation

From these you can solve for the angle

angle = 2 * atan2(norm(Q12(2:4)),Q12(1))

See also this post:

and this post:

Silas Waxter
on 17 Aug 2019

James Tursa
on 19 Aug 2019

Silas Waxter
on 19 Aug 2019

Ok thanks.

Sign in to comment.

Answer by Jim Riggs
on 17 Aug 2019

Edited by Jim Riggs
on 17 Aug 2019

I am more comfortable working with direction cosine matrices, so the way I would do this is to first convert the quaternions to DCM's;

Assume Quaternion A represents the orientation of body A in the I frame

Quaternion B represents the orientation of Body B in the I frame.

The direction cosine matrix, C, that transforms from I to A is defined as:

If the Quaternion is defined as [a, b, c, d], (where a is the scalar part and b, c, d is the vector part) then the direction cosine matrix in terms of the quaternion is

So, first compute the direction cosine matrix from quaternion A (DCMA) and from quaternion B (DCMB).

Now the direction cosine matrix for the transformation from A to B is

DCMAB = DCMB * transpose(DCMA).

Now that you have the transformation matrix from A to B, you can get the Euler angles or rotation vector from this DCM.

Using DCMAB, this gives the rotation vector from A to B.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.