dot product of two quaternion rotations
Should it be 2 x acos(dot) to get the angle between quaternions.
Just NOTE: acos(dot) is very not stable from numerical point of view.
as was said previos, q = q1^-1 * q2 and than angle = 2*atan2(q.vec.length(), q.w)
The dot product for quaternions is simply the standard Euclidean dot product in 4D:
dot = left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w
Then the angle your are looking for is the arccos
of the dot product (note that the dot product is not the angle): acos(dot)
.
However, if you are looking for the relative rotation between two quaternions, say from q1
to q2
, you should compute the relative quaternion q = q1^-1 * q2
and then find the rotation associated withq
.