dot product of two quaternion rotations
dot-product, java, math, quaternions, rotation
Solution
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 with`q`.
Problem
I understand that the dot (or inner) product of two quaternions is the angle between the rotations (including the axis-rotation). This makes the dot product equal to the angle between two points on the quaternion hypersphere. I can not, however, find how to actually compute the dot product. Any help would be appreciated! current code: ``` public static float dot(Quaternion left, Quaternion right){ float angle; //compute return angle; } ``` Defined are Quaternion.w, Quaternion.x, Quaternion.y, and Quaternion.z. Note: It can be assumed that the quaternions are normalised.