how to offset a rotation contained in a unit quaternion rotation from the origin of a rigid object.

396 Views Asked by At

I'm using Unity3D for a project. The way it handles sorting transformations is with a 3vector-unit quaternion-3vector "sandwich" (the 1st vector for position, the quaternion for rotation, and the 2nd vector for uniform axis scale). When you add a rotation to a transform it rotates the object around the origin of the mesh (usually the center of the object), my question is, is there a way to rotate an object around an "offset" from the object's center mathematically? is short move the rotation itself to a new position, and still influence the object? (see figure for clarity)enter image description here

1

There are 1 best solutions below

0
On

In 3d you can rotate around an arbitrary axis, shifted from the origin, by translating the object, then rotating and then translate back.

Translation is used to shift the rotation from the origin. You can use the coordinates of the new "center of rotation" to be the tranlation vector.

Suppose you have a function $Q : R^3 \rightarrow R^3$ that rotates a 3d vector using quaternions.

$$v' = Q(v - c) + c$$

Where $c$ is the new center of rotation, $v$ is the vector you want to rotate around $c$ and $v'$ is the rotated vector.

You can also put the above in matrix notation:

$$M = T_c R T_c^{-1}$$

Where the matrix $M$ is the shifted rotation matrix, $T_c$ is a translation matrix and $R$ is a rotation matrix derived from a quaternion. All matrices are $4 \times 4$. Here I assume your vectors are expressed in homogeneous coordinates. So you can apply $M$ to a homogeneous vector $v$ as:

$$v' = M v$$

You can even mix matrix and quaternions like:

$$v' = T_c Q(T_c^{-1} v)$$

Here we are assuming that $Q : R^4 \rightarrow R^4$ i.e., $Q$ is rotating homogeneous vectors.