affine
esta.general.affine
¶
Linear algebra operations and helpers.
Taken from the link (scikit-ued: https://github.com/LaurentRDC/scikit-ued/)
Inspired by Christoph Gohlke's transformation.py (link: http://www.lfd.uci.edu/~gohlke/ )
affine_map(array)
¶
Extends 3x3 transform matrices to 4x4, i.e. general affine transforms.
Parameters:
-
array(ndarray, shape {(3,3), (4,4)}) –Transformation matrix. If shape = (4,4), returned intact.
Returns:
-
extended((ndarray, shape(4, 4))) –
transform(matrix, array)
¶
Applies a matrix transform on an array.
Parameters:
-
matrix(ndarray, shape {(3,3), (4,4)}) –Transformation matrix.
-
array(ndarray, shape {(3,), (3,3), (4,4)}) –Array to be transformed. Either a 1x3 vector, or a transformation matrix in 3x3 or 4x4 shape.
Returns:
-
transformed(ndarray) –Transformed array, either a 1D vector or a 4x4 transformation matrix
Raises¶
ValueError : If the transformation matrix is neither 3x3 or 4x4
translation_matrix(direction)
¶
Return matrix to translate by direction vector.
Parameters:
-
direction((array_like, shape(3))) –
Returns:
-
translation(`~numpy.ndarray`, shape (4,4)) –4x4 translation matrix.
change_of_basis(basis1, basis2=(e1, e2, e3))
¶
Returns the matrix that goes from one basis to the other.
Parameters:
-
basis1(list of array_like, shape (3,)) –First basis -
basis2(list of array_like, shape (3,), default:(e1, e2, e3)) –Second basis. By default, this is the standard basis
Returns:
-
cob(`~numpy.ndarray`, shape (3,3)) –Change-of-basis matrix that, applied to
basis, will returnbasis2.
is_basis(basis)
¶
Returns true if the set of vectors forms a basis. This is done by checking whether basis vectors are independent via an eigenvalue calculation.
Parameters:
-
basis(list of array-like, shape (3,)) –
Returns:
-
out(bool) –Whether or not the basis is valid.
is_rotation_matrix(matrix)
¶
Checks whether a matrix is orthogonal with unit determinant (1 or -1), properties of rotation matrices.
Parameters:
-
matrix(ndarray, shape {(3,3), (4,4)}) –Rotation matrix candidate. If (4,4) matrix is provided, only the top-left block matrix of (3,) is checked
Returns:
-
result(bool) –If True, input could be a rotation matrix.
rotation_matrix(angle, axis=(0, 0, 1))
¶
Return matrix to rotate about axis defined by direction around the origin [0,0,0]. To combine rotation and translations, see http://www.euclideanspace.com/maths/geometry/affine/matrix4x4/index.htm
Parameters:
-
angle(float) –Rotation angle [rad] -
axis(array-like of length 3, default:(0, 0, 1)) –Axis about which to rotate
Returns:
-
matrix(`~numpy.ndarray`, shape (3,3)) –Rotation matrix.
See also
translation_rotation_matrix
translation_rotation_matrix(angle, axis, translation)
¶
Returns a 4x4 matrix that includes a rotation and a translation.
Parameters:
-
angle(float) –Rotation angle [rad] -
axis(array-like of length 3) –Axis about which to rotate -
translation((array_like, shape(3))) –Translation vector
Returns:
-
matrix(`~numpy.ndarray`, shape (4,4)) –Affine transform matrix.
change_basis_mesh(xx, yy, zz, basis1, basis2)
¶
Changes the basis of meshgrid arrays.
Parameters:
-
xx(ndarrays) –Arrays of equal shape, such as produced by numpy.meshgrid.
-
yy(ndarrays) –Arrays of equal shape, such as produced by numpy.meshgrid.
-
zz(ndarrays) –Arrays of equal shape, such as produced by numpy.meshgrid.
-
basis1(list of ndarrays, shape(3,)) –Basis of the mesh
-
basis2(list of ndarrays, shape(3,)) –Basis in which to express the mesh
Returns:
-
XX, YY, ZZ : `~numpy.ndarray`–
minimum_image_distance(xx, yy, zz, lattice)
¶
Returns a periodic array according to the minimum image convention.
Parameters:
-
xx(ndarrays) –Arrays of equal shape, such as produced by numpy.meshgrid. -
yy(ndarrays) –Arrays of equal shape, such as produced by numpy.meshgrid. -
zz(ndarrays) –Arrays of equal shape, such as produced by numpy.meshgrid. -
lattice(list of ndarrays, shape(3,)) –Basis of the mesh
Returns:
-
r(`~numpy.ndarray`) –Minimum image distance over the lattice