{ } Raw JSON

bundles / scipy 1.18.0 / scipy / spatial / transform / _rigid_transform / RigidTransform / from_components

staticmethod

scipy.spatial.transform._rigid_transform:RigidTransform.from_components

source: /scipy/spatial/transform/_rigid_transform.py:689

Signature

staticmethoddef from_components(translation: ArrayLike, rotation: Rotation) → RigidTransform

Summary

Initialize a rigid transform from translation and rotation components.

Extended Summary

When creating a rigid transform from a translation and rotation, the translation is applied after the rotation, such that tf = Tf.from_components(translation, rotation) is equivalent to tf = Tf.from_translation(translation) * Tf.from_rotation(rotation).

When applying a transform to a vector v, the result is the same as if the transform was applied to the vector in the following way: tf.apply(v) == translation + rotation.apply(v)

Parameters

translation : array_like, shape (..., 3)

Translation vectors. Each translation[..., :] represents a 3D translation vector.

rotation : `Rotation` instance

Rotation objects. The shape must be broadcastable with the translation shape.

Returns

transform : `RigidTransform` instance

Rigid transform objects. The shape is determined by broadcasting the translation and rotation shapes together.

Examples

from scipy.spatial.transform import RigidTransform as Tf
from scipy.spatial.transform import Rotation as R
import numpy as np
✓
Creating from a single rotation and translation:
t = np.array([2, 3, 4])
r = R.from_euler("ZYX", [90, 30, 0], degrees=True)
✓
r.as_matrix()
✗
array([[ 0.     , -1.     ,  0.     ],
       [ 0.86603,  0.     ,  0.5    ],
       [-0.5    ,  0.     ,  0.86603]])
tf = Tf.from_components(t, r)
✓
tf.rotation.as_matrix()
✗
array([[ 0.     , -1.     ,  0.     ],
       [ 0.86603,  0.     ,  0.5    ],
       [-0.5    ,  0.     ,  0.86603]])
tf.translation
tf.single
✓
True
When applying a transform to a vector ``v``, the result is the same as if the transform was applied to the vector in the following way: ``tf.apply(v) == translation + rotation.apply(v)``
r.apply([1, 0, 0])
t + r.apply([1, 0, 0])
tf.apply([1, 0, 0])
✗
array([2.     , 3.86603, 3.5    ])

Aliases

  • scipy.spatial.transform.RigidTransform.from_components