Main Content

mtimes, *

Quaternion multiplication

Description

quatC = A*B implements quaternion multiplication if either A or B is a quaternion. Either A or B must be a scalar.

You can use quaternion multiplication to compose rotation operators:

  • To compose a sequence of frame rotations, multiply the quaternions in the order of the desired sequence of rotations. For example, to apply a p quaternion followed by a q quaternion, multiply in the order pq. The rotation operator becomes (pq)v(pq), where v represents the object to rotate specified in quaternion form. * represents conjugation.

  • To compose a sequence of point rotations, multiply the quaternions in the reverse order of the desired sequence of rotations. For example, to apply a p quaternion followed by a q quaternion, multiply in the reverse order, qp. The rotation operator becomes (qp)v(qp).

example

Examples

collapse all

Create a 4-by-1 column vector, A, and a scalar, b. Multiply A times b.

A = quaternion(randn(4,4))
A = 4×1 quaternion array
      0.53767 +  0.31877i +   3.5784j +   0.7254k
       1.8339 -   1.3077i +   2.7694j - 0.063055k
      -2.2588 -  0.43359i -   1.3499j +  0.71474k
      0.86217 +  0.34262i +   3.0349j -  0.20497k

b = quaternion(randn(1,4))
b = quaternion
    -0.12414 +  1.4897i +   1.409j +  1.4172k

C = A*b
C = 4×1 quaternion array
      -6.6117 +   4.8105i +  0.94224j -   4.2097k
      -2.0925 +   6.9079i +   3.9995j -   3.3614k
       1.8155 -   6.2313i -    1.336j -     1.89k
      -4.6033 +   5.8317i + 0.047161j -    2.791k

Input Arguments

collapse all

Input to multiply, specified as a quaternion object, an array of quaternion objects of any dimensionality, a real scalar, or an array of real numbers of any dimensionality. Numeric values must be of data type single or double.

If B is nonscalar, then A must be scalar.

Input to multiply, specified as a quaternion object, an array of quaternion objects of any dimensionality, a real scalar, or an array of real numbers of any dimensionality. Numeric values must be of data type single or double.

If A is nonscalar, then B must be scalar.

Output Arguments

collapse all

Quaternion product, returned as a quaternion object or an array of quaternion objects.

Algorithms

collapse all

References

[1] Kuipers, Jack B. Quaternions and Rotation Sequences: A Primer with Applications to Orbits, Aerospace, and Virtual Reality. Princeton, NJ: Princeton University Press, 2007.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2018a

See Also

Functions

Objects