jaxtransform3d.rotations.apply_matrix#
- jaxtransform3d.rotations.apply_matrix(R: Array | ndarray | bool_ | number | bool | int | float | complex, v: Array | ndarray | bool_ | number | bool | int | float | complex) Array [source]#
Apply rotation matrix to vector.
Computes the matrix-vector product
\[\boldsymbol{w} = \boldsymbol{R} \boldsymbol{v}.\]- Parameters:
- Rarray-like, shape (…, 3, 3) or (3, 3)
Rotation matrix.
- varray-like, shape (…, 3) or (3,)
3d vector.
- Returns:
- warray, shape (…, 3) or (3,)
3d vector.
See also
apply_quaternion
Apply rotation represented by a unit quaternion.
Examples
>>> import jax.numpy as jnp >>> from jaxtransform3d.rotations import ( ... apply_matrix, matrix_from_compact_axis_angle) >>> a = jnp.array([[0.5 * jnp.pi, 0.0, 0.0], ... [0.0, 0.5 * jnp.pi, 0.0]]) >>> R = matrix_from_compact_axis_angle(a) >>> v = jnp.array([[0.5, 1.0, 2.5], [1, 2, 3]]) >>> apply_matrix(R[0], v[0]).round(7) Array([ 0.5, -2.5, 1. ], ...) >>> apply_matrix(R, v) Array([[ 0.5, -2.5, 1. ], [ 3. , 2. , -1. ]], dtype=float32)