astrodynx.utils.rotmat3dz

Contents

astrodynx.utils.rotmat3dz#

astrodynx.utils.rotmat3dz(angle)[source]#

Returns a 3x3 rotation matrix for a given angle around the z-axis.

Parameters:

angle (ArrayLike) – The angle in radians to rotate around the z-axis.

Return type:

Array

Returns:

A 3x3 rotation matrix that rotates vectors around the z-axis by the specified angle.

Notes

The rotation matrix is defined as:

\[\begin{split} R_z(\theta) = \begin{bmatrix} \cos(\theta) & -\sin(\theta) & 0 \\ \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{bmatrix} \end{split}\]
where \(\theta\) is the angle of rotation.

References

Battin, 1999, pp.85.

Examples

Creating a rotation matrix for a 90-degree rotation (π/2 radians):

>>> import jax.numpy as jnp
>>> import astrodynx as adx
>>> angle = jnp.pi / 2
>>> jnp.allclose(adx.utils.rotmat3dz(angle), jnp.array([[0., -1., 0.], [1., 0., 0.], [0., 0., 1.]]), atol=1e-7)
Array(True, dtype=bool)

Broadcasting with an array of angles:

>>> angles = jnp.array([0.0, jnp.pi / 2])
>>> results = jnp.stack([adx.utils.rotmat3dz(a) for a in angles])
>>> expected0 = jnp.eye(3)
>>> expected1 = jnp.array([[0., -1., 0.], [1., 0., 0.], [0., 0., 1.]])
>>> jnp.allclose(results[0], expected0, atol=1e-7)
Array(True, dtype=bool)
>>> jnp.allclose(results[1], expected1, atol=1e-7)
Array(True, dtype=bool)