Skip to main content
`Ctrl`+`K`
scipy.spatial.transform.RigidTransform.

# __pow__

RigidTransform.__pow__(self, float n)

  Compose this transform with itself n times.

  A rigid transform p when raised to non-integer powers can be thought of as finding a fraction of the transformation. For example, a power of 0.5 finds a “halfway” transform from the identity to p.

  This is implemented by applying screw linear interpolation (ScLERP) between p and the identity transform, where the angle of the rotation component is scaled by n, and the translation is proportionally adjusted along the screw axis.

  `q = p ** n` can also be expressed as `q = RigidTransform.from_exp_coords(p.as_exp_coords() * n)`.

  If n is negative, then the transform is inverted before the power is applied. In other words, `p ** -abs(n) == p.inv() ** abs(n)`.

  Parameters:
    n float

      The number of times to compose the transform with itself.

  Returns:
    `RigidTransform` instance

      If the input Rotation p contains N multiple rotations, then the output will contain N rotations where the i th rotation is equal to `p[i] ** n`.

  Notes

  There are three notable cases: if `n == 1` then a copy of the original transform is returned, if `n == 0` then the identity transform is returned, and if `n == -1` then the inverse transform is returned.

  Note that fractional powers `n` which effectively take a root of rotation, do so using the shortest path smallest representation of that angle (the principal root). This means that powers of `n` and `1/n` are not necessarily inverses of each other. For example, a 0.5 power of a +240 degree rotation will be calculated as the 0.5 power of a -120 degree rotation, with the result being a rotation of -60 rather than +120 degrees.

  Examples

      >>> from scipy.spatial.transform import RigidTransform as Tf
      >>> import numpy as np

  A power of 2 returns the transform composed with itself:

      >>> tf = Tf.from_translation([1, 2, 3])
      >>> (tf ** 2).translation
      array([2., 4., 6.])
      >>> (tf ** 2).as_matrix()
      array([[1., 0., 0., 2.],
             [0., 1., 0., 4.],
             [0., 0., 1., 6.],
             [0., 0., 0., 1.]])

  A negative power returns the inverse of the transform raised to the absolute value of n:

      >>> (tf ** -2).translation
      array([-2., -4., -6.])
      >>> np.allclose((tf ** -2).as_matrix(), (tf.inv() ** 2).as_matrix(),
      ...             atol=1e-12)
      True

  A power of 0 returns the identity transform:

      >>> (tf ** 0).as_matrix()
      array([[1., 0., 0., 0.],
             [0., 1., 0., 0.],
             [0., 0., 1., 0.],
             [0., 0., 0., 1.]])

  A power of 1 returns a copy of the original transform:

      >>> (tf ** 1).as_matrix()
      array([[1., 0., 0., 1.],
             [0., 1., 0., 2.],
             [0., 0., 1., 3.],
             [0., 0., 0., 1.]])

  A fractional power returns a transform with a scaled rotation and translated along the screw axis. Here we take the square root of the transform, which when squared recovers the original transform:

      >>> tf_half = (tf ** 0.5)
      >>> tf_half.translation
      array([0.5, 1., 1.5])
      >>> (tf_half ** 2).as_matrix()
      array([[1., 0., 0., 1.],
             [0., 1., 0., 2.],
             [0., 0., 1., 3.],
             [0., 0., 0., 1.]])