bundles / scipy 1.17.1 / scipy / spatial / transform / _rotation / Rotation / __pow__
function
scipy.spatial.transform._rotation:Rotation.__pow__
Signature
def __pow__ ( self , n : float | Array , modulus : None = None ) → Rotation Summary
Compose this rotation with itself n times.
Extended Summary
Composition of a rotation p with itself can be extended to non-integer n by considering the power n to be a scale factor applied to the angle of rotation about the rotation's fixed axis. The expression q = p ** n can also be expressed as q = Rotation.from_rotvec(n * p.as_rotvec()).
If n is negative, then the rotation is inverted before the power is applied. In other words, p ** -abs(n) == p.inv() ** abs(n).
Parameters
n: float | ArrayThe number of times to compose the rotation with itself. If
nis an array, then it must be 0d or 1d with shape (1,).modulus: NoneThis overridden argument is not applicable to Rotations and must be
None.
Returns
power: `Rotation` instanceThe resulting rotation will be of the same shape as the original rotation object. Each element of the output is the corresponding element of the input rotation raised to the power of
n.
Notes
For example, a power of 2 will double the angle of rotation, and a power of 0.5 will halve the angle. There are three notable cases: if n == 1 then the original rotation is returned, if n == 0 then the identity rotation is returned, and if n == -1 then p.inv() 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.
Array API Standard Support
__pow__ has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ✅ PyTorch ✅ ✅ JAX ✅ ✅ Dask ⛔ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
from scipy.spatial.transform import Rotation as R
✓p = R.from_rotvec([1, 0, 0]) q = p ** 2 q.as_rotvec() r = p ** 0.5✓
r.as_rotvec()
✗p = R.from_rotvec([0, 0, 120], degrees=True)
✓((p ** 2) ** 0.5).as_rotvec(degrees=True)
✗Aliases
-
scipy.spatial.transform.Rotation.__pow__