Rotation

This is the pydoc code for the rotation module.

This file contains useful functions that define rotation matrices.

molli.math.rotation.rotation_matrix_from_vectors(_v1: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], _v2: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], tol=1e-08) ndarray

Rotation Matrix (vector-to-vector definition) —

Computes a 3x3 rotation matrix that transforms v1/|v1| -> v2/|v2| tol detects a situation where dot(v1, v2) ~ -1.0 and returns a diag(-1,-1, 1) matrix instead. NOTE [Is this correct?!] This may be improved by figuring a more correct asymptotic behavior, but works for the present purposes.

returns matrix [R], that satisfies the following equation: v1 @ [R] / |v1| == v2 / |v2|

Inspired by https://en.wikipedia.org/wiki/Rotation_matrix https://math.stackexchange.com/questions/180418/calculate-rotation-matrix-to-align-vector-a-to-vector-b-in-3d

molli.math.rotation.rotation_matrix_from_axis(_axis: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], angle: float)

refs https://mathworld.wolfram.com/RodriguesRotationFormula.html https://math.stackexchange.com/questions/142821/matrix-for-rotation-around-a-vector