# Quaternion: composition of rotations/orientations to determine relative orientation

I started working with quaternions quite a while ago and I ask the following question because I am confused about several different interpretations or contradicting truths out there in the world wide web concerning quaternions and composition of rotations.

Given are two unit orientation quaternions, each representing an orientation of a rigid body of the earth frame relative to the corresponding body frame ($_E^Aq_A ,_E^Bq_B$). The final target is to determine the joint angle or rather orientation between $q_A$(e.g. upper arm) and $q_B$ (e.g. forearm). From my understanding and the description of the movement of a joint being expressed as orientation of the distal segment relative to the proximal segment of the joint, the equation (1) from this Paper can be transformed to quaternion notation (2) (with $^*$ being the inverse/conjugate of unit quaternion):

(1) $$R_{joint} = ^ER_{proximal}^T (^ER_{distal})$$

(2) $$^{proximal}_{distal}q_{joint} = q_{proximal} ^* \otimes q_{distal}$$

Thus, for the elbow joint example this means:

$$q_{joint} = q_A ^* \otimes q_B$$

I know that the order matters because of the non-commutative algebra of quaternions, just like using rotation matrices. My question is now if the given formula, particularly the conjugate of the left quaternion, gives me what I wanted, hence, the orientation quaternion of the joint = relative orientation between frame A and B, or if the orientation quaternion of frame B relative/with respect to frame A is computed by $$q_{joint} = q_A \otimes q_B ^*$$ ?

As far as I interpret equation (2) is that the orientation of the proximal body is back-rotated relative to the earth frame from which the relative orientation between distal and proximal body is determined by the quaternion multiplication. Hopefully, someone is out there and can explain me the difference. Thanks a lot for your attention.

P.S.: Here the difference in order of quaternion multiplication is given by $q_2 \otimes q_1$ as absolute frame of reference operation and $q_1 \otimes q_2$ as frame of reference of rotating object. Equation (2) describes the first one, correct? If this does not coincide with my previous question, I could open another one.

your first equation ($q_{joint} = q_A ^* \otimes q_B$) is correct. Remember the operations work from right to left, so the right terms represents a vector from the B frame to E frame, then the second one represents a vector from the E frame to the A frame. Thus the composition of the to gives you a quaternion from B to A (i.e. the orientation of frame B in frame A). (I am speaking in the passive picture here.)