ktk.geometry.create_transforms#

create_transforms(seq=None, angles=None, translations=None, scales=None, *, degrees=False)[source]#

Create series of transforms based on angles, translatations and scales.

Create an Nx4x4 series of homogeneous transform matrices based on series of angles, translatations and scales.

Parameters
  • seq (Optional[str]) – Optional. Specifies sequence of axes for rotations. Up to 3 characters belonging to the set {“X”, “Y”, “Z”} for intrinsic rotations (moving axes), or {“x”, “y”, “z”} for extrinsic rotations (fixed axes). Extrinsic and intrinsic rotations cannot be mixed in one function call. Required if angles is specified.

  • angles (Optional[ArrayLike]) –

    Optional array_like of shape (N,) or (N, [1 or 2 or 3]). Angles are specified in radians (if degrees is False) or degrees (if degrees is True).

    For a single-character seq, angles can be:

    • array_like with shape (N,), where each angle[i] corresponds to a single rotation;

    • array_like with shape (N, 1), where each angle[i, 0] corresponds to a single rotation.

    For 2- and 3-character seq, angles is an array_like with shape (N, W) where each angle[i, :] corresponds to a sequence of Euler angles and W is the length of seq.

  • translations (Optional[ArrayLike]) – Optional array_like of shape (N, 3) or (N, 4). This corresponds to the translation part of the generated series of homogeneous transforms.

  • scales (Optional[ArrayLike]) – Optional array_like of shape (N, ) that corresponds to the scale to apply uniformly on the three axes. By default, no scale is included.

  • degrees – If True, then the given angles are in degrees. Default is False.

Returns

An Nx4x4 series of homogeneous transforms.

Return type

np.ndarray

Examples

Create a series of two homogeneous transforms that rotates 0, then 90 degrees around x:

>>> import kineticstoolkit.lab as ktk
>>> ktk.geometry.create_transforms(seq="x", angles=[0, 90], degrees=True)
array([[[ 1.,  0.,  0.,  0.],
        [ 0.,  1.,  0.,  0.],
        [ 0.,  0.,  1.,  0.],
        [ 0.,  0.,  0.,  1.]],

       [[ 1.,  0.,  0.,  0.],
        [ 0.,  0., -1.,  0.],
        [ 0.,  1.,  0.,  0.],
        [ 0.,  0.,  0.,  1.]]])

Create an homogeneous transform that converts millimeters to meters

>>> import kineticstoolkit.lab as ktk
>>> ktk.geometry.create_transforms(scales=[0.001])
array([[[0.001, 0.   , 0.   , 0.   ],
        [0.   , 0.001, 0.   , 0.   ],
        [0.   , 0.   , 0.001, 0.   ],
        [0.   , 0.   , 0.   , 1.   ]]])