scipy.spatial.transform.Rotation.concatenate#

classmethod Rotation.concatenate(cls, rotations)#

Concatenate a sequence of Rotation objects into a single object.

This is useful if you want to, for example, take the mean of a set of rotations and need to pack them into a single object to do so.

Parameters:
rotationssequence of Rotation objects

The rotations to concatenate.

Returns:
concatenatedRotation instance

The concatenated rotations.

Notes

New in version 1.8.0.

Examples

>>> from scipy.spatial.transform import Rotation as R
>>> r1 = R.from_rotvec([0, 0, 1])
>>> r2 = R.from_rotvec([0, 0, 2])
>>> rc = R.concatenate([r1, r2])
>>> rc.as_rotvec()
array([[0., 0., 1.],
       [0., 0., 2.]])
>>> rc.mean().as_rotvec()
array([0., 0., 1.5])

Note that it may be simpler to create the desired rotations by passing in a single list of the data during initialization, rather then by concatenating:

>>> R.from_rotvec([[0, 0, 1], [0, 0, 2]]).as_rotvec()
array([[0., 0., 1.],
       [0., 0., 2.]])