Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dot product of two quaternion rotations

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.

like image 594
Kent Avatar asked Feb 02 '14 17:02

Kent


People also ask

What is the dot product of two quaternions?

The dot-product (inner product) of two quaternions is their usual vector dot-product: ˙p· ˙q = p0q0 + pxqx + pyqy + pzqz. a vector. A unit quaternion has squared length one.

How do you combine quaternion rotations?

To rotate a vector v=ix+jy+kz by a quaternion q you compute vq=qvq−1. So if q and q′ are two rotation quaternions, to rotate by q then q′ you calculate (vq)q′=q′qvq−1q′−1=q′qv(q′q)−1=vq′q.

How are quaternions multiplied?

Multiplication of a quaternion, q, by its inverse, q− 1, results in the multiplicative identity [1, (0, 0, 0)]. A unit-length quaternion (also referred to here as a unit quaternion), , is created by dividing each of the four components by the square root of the sum of the squares of those components (Eq. 2.28).

How do you rotate a quaternion by another quaternion?

Use the Quaternion operator * . In Unity, when you multiply two quaternions, it applies the second quaternion (expressed in global axes) to the first quaternion along the local axes produced after the first Quaternion ). So, if you want to do the equivalent of Rotate(q2, Space.


Video Answer


1 Answers

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.

like image 174
user3146587 Avatar answered Nov 10 '22 06:11

user3146587