pyvista_validation.validate.validate_rotation#
- pyvista_validation.validate.validate_rotation(rotation: RotationLike, must_have_handedness: Literal['right', 'left'] | None = None, *, tolerance: float = 1e-06, name: str = 'Rotation')#
Validate a rotation as a 3x3 matrix.
The rotation is valid if it is orthogonal and has a determinant of
1(right-handed or “proper” rotation) or-1(left-handed or “improper” rotation). By default, right- and left-handed rotations are allowed. Usemust_have_handednessto restrict the handedness.- Parameters:
- rotationRotationLike
3x3 rotation matrix or a SciPy
Rotationobject.- must_have_handedness‘right’ | ‘left’ | None, default: None
Check if the rotation has a specific handedness. If
right, the determinant must be1. Ifleft, the determinant must be-1. By default, either handedness is allowed.- tolerancefloat, default: 1e-6
Tolerance used for checking orthogonality.
- namestr, default: “Rotation”
Variable name to use in the error messages if any of the validation checks fail.
- Returns:
- np.ndarray
Validated 3x3 rotation matrix.
Examples
Validate a rotation matrix. The identity matrix is used as a toy example.
>>> import numpy as np >>> from pyvista_validation import validate_rotation >>> rotation = np.eye(3) >>> validate_rotation(rotation) array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
By default, left-handed rotations (which include reflections) are allowed.
>>> rotation *= -1 # Add reflections >>> validate_rotation(rotation) array([[-1., -0., -0.], [-0., -1., -0.], [-0., -0., -1.]])