jaxtransform3d.rotations.matrix_inverse#
- jaxtransform3d.rotations.matrix_inverse(R: Array | ndarray | bool_ | number | bool | int | float | complex) Array [source]#
Invert rotation matrix.
The inverse of a rotation matrix \(\boldsymbol{R} \in SO(3)\) is its transpose \(\boldsymbol{R}^{-1} = \boldsymbol{R}^T\) because of the orthonormality constraint \(\boldsymbol{R}\boldsymbol{R}^T = \boldsymbol{I}\) (see
norm_matrix()
).- Parameters:
- Rarray-like, shape (…, 3, 3)
Rotation matrix.
- Returns:
- R_invarray, shape (…, 3, 3)
Inverted rotation matrix.
See also
quaternion_conjugate
Inverts the rotation represented by a unit quaternion.
Examples
>>> import jax.numpy as jnp >>> from jaxtransform3d.rotations import matrix_inverse
Inverting a single rotation matrix:
>>> matrix_inverse(jnp.eye(3)) Array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]], dtype=float32)
Inversion is inhenrently vectorized. You can easily apply it to any number of dimensions, e.g., a 1D list of rotation matrices:
>>> import jax >>> from jaxtransform3d.rotations import matrix_from_compact_axis_angle >>> key = jax.random.PRNGKey(42) >>> a = jax.random.normal(key, shape=(20, 3)) >>> R = matrix_from_compact_axis_angle(a) >>> R_inv = matrix_inverse(R) >>> R_inv Array([[[...]]], dtype=float32) >>> R_inv.shape (20, 3, 3) >>> from jaxtransform3d.rotations import compose_matrices >>> I = compose_matrices(R, R_inv) >>> I[0].round(5) Array([[...1., ...0., ...0.], [...0., ...1., ...0.], [...0., ...0., ...1.]], ...)
Or a 2D list of rotation matrices:
>>> R = R.reshape(5, 4, 3, 3) >>> R_inv = matrix_inverse(R) >>> R_inv Array([[[[...]]]], dtype=float32) >>> R_inv.shape (5, 4, 3, 3) >>> I = compose_matrices(R, R_inv) >>> I[0, 0].round(5) Array([[...1., ...0., ...0.], [...0., ...1., ...0.], [...0., ...0., ...1.]], ...)