pyvista.core._validation.validate.validate_axes#

validate_axes(
*axes,
normalize=True,
must_be_orthogonal=True,
must_have_orientation='right',
name='Axes',
)[source]#

Validate 3D axes vectors.

By default, the axes are normalized and checked to ensure they are orthogonal and have a right-handed orientation.

Parameters:
*axesarray_like

Axes to be validated. Axes may be specified as a single argument of a 3x3 array of row vectors or as separate arguments for each 3-element axis vector. If only two vectors are given and must_have_orientation is not None, the third vector is automatically calculated as the cross-product of the two vectors such that the axes have the correct orientation.

normalizebool, default: True

If True, the axes vectors are individually normalized to each have a norm of 1.

must_be_orthogonalbool, default: True

Check if the axes are orthogonal. If True, the cross product between any two axes vectors must be parallel to the third.

must_have_orientationstr, default: ‘right’

Check if the axes have a specific orientation. If right, the cross-product of the first axis vector with the second must have a positive direction. If left, the direction must be negative. If None, the orientation is not checked.

namestr, default: “Axes”

Variable name to use in the error messages if any of the validation checks fail.

Returns:
np.ndarray

Validated 3x3 axes array of row vectors.

Examples

Validate an axes array.

>>> import numpy as np
>>> from pyvista import _validation
>>> _validation.validate_axes(np.eye(3))
array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])

Validate individual axes vectors as a 3x3 array.

>>> _validation.validate_axes([1, 0, 0], [0, 1, 0], [0, 0, 1])
array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])

Create a validated left-handed axes array from two vectors.

>>> _validation.validate_axes(
...     [1, 0, 0], [0, 1, 0], must_have_orientation='left'
... )
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0., -1.]])