bundles / scipy latest / scipy / spatial / transform / _rigid_transform / RigidTransform / __mul__
function
scipy.spatial.transform._rigid_transform:RigidTransform.__mul__
source: build-install/usr/lib/python3.14/site-packages/scipy/spatial/transform/_rigid_transform.py:1453
Signature
def __mul__(self, other: RigidTransform | Rotation) → RigidTransformSummary
Compose this transform with the other.
Extended Summary
If p and q are two transforms, then the composition of 'q followed by p' is equivalent to p * q. In terms of transformation matrices, the composition can be expressed as p.as_matrix() @ q.as_matrix().
In terms of translations and rotations, the composition when applied to a vector v is equivalent to p.translation + p.rotation.apply(q.translation) + (p.rotation * q.rotation).apply(v).
This function supports composition of multiple transforms at a time using broadcasting rules. The resulting shape for two RigidTransform instances p and q is np.broadcast_shapes(p.shape, q.shape).
If other is a Rotation, it is automatically promoted to a RigidTransform with zero translation.
Parameters
other: `RigidTransform` or `Rotation` instanceTransform(s) or rotation(s) to be composed with this one. The shapes must be broadcastable.
Returns
: `RigidTransform` instanceThe composed transform.
Examples
from scipy.spatial.transform import RigidTransform as Tf from scipy.spatial.transform import Rotation as R import numpy as np✓
tf1 = Tf.from_translation([1, 0, 0]) tf2 = Tf.from_translation([0, 1, 0]) tf = tf1 * tf2 tf.translation tf.single✓
TrueWhen applied to a vector, the composition of two transforms is applied in right-to-left order.
t1, r1 = [1, 2, 3], R.from_euler('z', 60, degrees=True) t2, r2 = [0, 1, 0], R.from_euler('x', 30, degrees=True) tf1 = Tf.from_components(t1, r1) tf2 = Tf.from_components(t2, r2) tf = tf1 * tf2✓
tf.apply([1, 0, 0]) tf1.apply(tf2.apply([1, 0, 0]))✗
array([0.63397, 3.36603, 3. ])When at least one of the transforms is not single, the result is a stack of transforms.
tf1 = Tf.from_translation([1, 0, 0]) tf2 = Tf.from_translation([[0, 2, 0], [0, 0, 3]]) tf = tf1 * tf2 tf.translation tf.single len(tf)✓
2Broadcasting rules apply when composing multiple transforms at a time.
tf1 = Tf.from_translation(np.ones((5, 1, 3))) # Shape (5, 1, 3) tf2 = Tf.from_translation(np.ones((1, 4, 3))) # Shape (1, 4, 3) tf = tf1 * tf2 # Shape (5, 4, 3) tf.translation.shape✓
(5, 4, 3)
Aliases
scipy.spatial.transform.RigidTransform.__mul__