rotation

m3sh.linalg.rotation(v, w, a)[source]

Rotation parameters.

Computes the values \(\cos(\varphi)\) and \(\sin(\varphi)\) of the rotation about the axis \(\mathbf{a}\) that aligns two vectors \(\mathbf{v}\) and \(\mathbf{w}\) of equal norm, i.e., using Rodrigues’ rotation formula we get

\[\mathbf{w} = \mathbf{v} \cos(\varphi) + (1-\cos(\varphi)) \mathbf{a} \mathbf{a}^T \mathbf{v} + (\mathbf{a} \times \mathbf{v}) \sin(\varphi).\]
Parameters:
  • v (ndarray, shape (3, )) – Vector in 3-space.

  • w (ndarray, shape (3, )) – Vector in 3-space.

  • a (ndarray, shape (3, )) – Unit vector in 3-space.

Returns:

  • cosphi (float) – Cosine of rotation angle.

  • sinphi (float) – Sine of rotation angle.

Note

The length preconditions on \(\mathbf{v}\) and \(\mathbf{w}\) are not checked. If \(\| \mathbf{v} \| \neq \| \mathbf{w} \|\) the formula

\[\lambda \mathbf{w} = \mathbf{v} \cos(\varphi) + (1-\cos(\varphi)) \mathbf{a} \mathbf{a}^T \mathbf{v} + (\mathbf{a} \times \mathbf{v}) \sin(\varphi)\]

holds with \(\lambda = \| \mathbf{v} \| / \| \mathbf{w} \|\).