astrodynx.utils.rotmat3dx#
- astrodynx.utils.rotmat3dx(angle)[source]#
Returns a 3x3 rotation matrix for a given angle around the x-axis.
- Parameters:
angle (
ArrayLike) – The angle in radians to rotate around the x-axis.- Return type:
- Returns:
A 3x3 rotation matrix that rotates vectors around the x-axis by the specified angle.
Notes
The rotation matrix is defined as:
\[\begin{split} R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos(\theta) & -\sin(\theta) \\ 0 & \sin(\theta) & \cos(\theta) \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.rotmat3dx(angle), jnp.array([[1., 0., 0.], [0., 0., -1.], [0., 1., 0.]]), 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.rotmat3dx(a) for a in angles]) >>> expected0 = jnp.eye(3) >>> expected1 = jnp.array([[1., 0., 0.], [0., 0., -1.], [0., 1., 0.]]) >>> jnp.allclose(results[0], expected0, atol=1e-7) Array(True, dtype=bool) >>> jnp.allclose(results[1], expected1, atol=1e-7) Array(True, dtype=bool)