Transformation of vector plus quaternion avoiding 4x4 matrix multiplication (using dual quaternion?)

266 Views Asked by At

We have a need to translate and rotate a 3d position with orientation (expressed as quaternion) [x, y, z, qx, qy, qz, qw] by a translation and rotation expressed as vector and quaternion [x', y', z', qx', qy', qz', qw'] to give resulting position and orientation [x'', y'', z'', qx'', qy'', qz'', qw''].

At the moment we use the following steps:

  • Compose [x, y, z, qx, qy, qz, qw] into affine 4x4 matrix with unit scale
  • Compose [x', y', z', qx', qy', qz', qw'] into affine 4x4 matrix with unit scale
  • Multiply the matrices
  • Decompose resulting 4x4 matrix into [x'', y'', z'', qx'', qy'', qz'', qw'']

I am looking for a more direct approach and think this involves dual quaternions, but am not sure.

EDIT

Worked example:

Take initial position (10,10,0) with orientation (0.7071068, 0, 0, 0.7071068) (Euler PI/2, 0, 0)

If we compose these into 4x4, we get:

$$\begin{bmatrix} 1&0&0&10\\ 0&0&-1&0\\ 0&1&0&0\\ 0&0&0&1 \end{bmatrix}$$

We want to translate this (5,0,0) and rotate (-0.7071068, 0, 0, 0.7071068) (Euler -PI/2, 0, 0) so we compose this also to get:

$$\begin{bmatrix} 1&0&0&5\\ 0&0&1&0\\ 0&-1&0&0\\ 0&0&0&1 \end{bmatrix}$$

Multiplying these gives:

$$\begin{bmatrix} 1&0&0&15\\ 0&1&0&0\\ 0&0&1&0\\ 0&0&0&1 \end{bmatrix}$$

This can be decomposed into position (15,0,0) and orientation (0,0,0,1).

Obviously this is a contrived case with simple numbers but hopefully makes the requirement clearer.