e3x.so3.rotations.alignment_rotation
- e3x.so3.rotations.alignment_rotation(u, v)[source]
Rotation matrix that aligns \(\vec{u}\) with \(\vec{v}\).
Calculates the \(3\times3\) rotation matrix that aligns the vector \(\vec{u}\) with the vector \(\vec{v}\) using the shortest possible arc. When \(\vec{u}\) and \(\vec{v}\) are exactly antiparallel, there are infinitely many paths with the same arc length and one of them is chosen at random.
Example
>>> import jax.numpy as jnp >>> import e3x >>> u = jnp.asarray([1., 0., 0.]) # Unit vector in x-direction. >>> v = jnp.asarray([0., 1., 0.]) # Unit vector in y-direction. >>> jnp.round(u @ e3x.so3.alignment_rotation(u, v), decimals=3) Array([0., 1., 0.], dtype=float32)
- Parameters:
u (
<class 'Float[Array, '... 3']'>) – Vector \(\vec{u}\).v (
<class 'Float[Array, '... 3']'>) – Vector \(\vec{v}\).
- Return type:
- Returns:
The \(3\times3\) rotation matrix.