# scipy.spatial.transform.Rotation.__mul__#

Rotation.__mul__()#

Compose this rotation with the other.

If p and q are two rotations, then the composition of ‘q followed by p’ is equivalent to p * q. In terms of rotation matrices, the composition can be expressed as `p.as_matrix().dot(q.as_matrix())`.

Parameters:
other`Rotation` instance

Object containing the rotations to be composed with this one. Note that rotation compositions are not commutative, so `p * q` is different from `q * p`.

Returns:
composition`Rotation` instance

This function supports composition of multiple rotations at a time. The following cases are possible:

• Either `p` or `q` contains a single rotation. In this case composition contains the result of composing each rotation in the other object with the single rotation.

• Both `p` and `q` contain `N` rotations. In this case each rotation `p[i]` is composed with the corresponding rotation `q[i]` and output contains `N` rotations.

Examples

```>>> from scipy.spatial.transform import Rotation as R
>>> import numpy as np
```

Composition of two single rotations:

```>>> p = R.from_quat([0, 0, 1, 1])
>>> q = R.from_quat([1, 0, 0, 1])
>>> p.as_matrix()
array([[ 0., -1.,  0.],
[ 1.,  0.,  0.],
[ 0.,  0.,  1.]])
>>> q.as_matrix()
array([[ 1.,  0.,  0.],
[ 0.,  0., -1.],
[ 0.,  1.,  0.]])
>>> r = p * q
>>> r.as_matrix()
array([[0., 0., 1.],
[1., 0., 0.],
[0., 1., 0.]])
```

Composition of two objects containing equal number of rotations:

```>>> p = R.from_quat([[0, 0, 1, 1], [1, 0, 0, 1]])
>>> q = R.from_rotvec([[np.pi/4, 0, 0], [-np.pi/4, 0, np.pi/4]])
>>> p.as_quat()
array([[0.        , 0.        , 0.70710678, 0.70710678],
[0.70710678, 0.        , 0.        , 0.70710678]])
>>> q.as_quat()
array([[ 0.38268343,  0.        ,  0.        ,  0.92387953],
[-0.37282173,  0.        ,  0.37282173,  0.84971049]])
>>> r = p * q
>>> r.as_quat()
array([[ 0.27059805,  0.27059805,  0.65328148,  0.65328148],
[ 0.33721128, -0.26362477,  0.26362477,  0.86446082]])
```