from_exp_coords#
- classmethod RigidTransform.from_exp_coords(cls, exp_coords)#
Initialize from exponential coordinates of transform.
This implements the exponential map that converts 6-dimensional real vectors to SE(3).
An exponential coordinate vector consists of 6 elements
[rx, ry, rz, vx, vy, vz]
. The first 3 encode rotation (and form a rotation vector used inRotation.from_rotvec
) and the last 3 encode translation (and form a translation vector for pure translations). The exponential mapping can be expressed as matrix exponentialT = exp(tau)
, whereT
is a 4x4 matrix representing a rigid transform andtau
is a 4x4 matrix formed from the elements of an exponential coordinate vector:tau = [ 0 -rz ry vx] [ rz 0 -rx vy] [-ry rx 0 vz] [ 0 0 0 1]
- Parameters:
- exp_coordsarray_like, shape (N, 6) or (6,)
A single exponential coordinate vector or a stack of exponential coordinate vectors. The expected order of components is
[rx, ry, rz, vx, vy, vz]
. The first 3 components encode rotation and the last 3 encode translation.
- Returns:
- transform
RigidTransform
instance A single transform or a stack of transforms.
- transform
Examples
>>> from scipy.spatial.transform import RigidTransform as Tf >>> import numpy as np
Creating from a single 6d vector of exponential coordinates:
>>> tf = Tf.from_exp_coords([ ... -2.01041204, -0.52983629, 0.65773501, ... 0.10386614, 0.05855009, 0.54959179]) >>> tf.as_matrix() array([[0.76406621, 0.10504613, -0.63652819, -0.10209961], [0.59956454, -0.47987325, 0.64050295, 0.40158789], [-0.2381705, -0.87102639, -0.42963687, 0.19637636], [0., 0., 0., 1.]]) >>> tf.single True
A vector of zeros represents the identity transform:
>>> tf = Tf.from_exp_coords(np.zeros(6)) >>> tf.as_matrix() array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]])
The last three numbers encode translation. If the first three numbers are zero, the last three components can be interpreted as the translation:
>>> tf_trans = Tf.from_exp_coords([0, 0, 0, 4.3, -2, 3.4]) >>> tf_trans.translation array([4.3, -2., 3.4])
The first three numbers encode rotation as a rotation vector:
>>> tf_rot = Tf.from_exp_coords([0.5, 0.3, 0.1, 0, 0, 0]) >>> tf_rot.rotation.as_rotvec() array([0.5, 0.3, 0.1])
Combining translation and rotation preserves the rotation vector, but changes the last three components as they encode translation and rotation:
>>> (tf_trans * tf_rot).as_exp_coords() array([0.5, 0.3, 0.1, 3.64305882, -1.25879559, 4.46109265])