amulet.utils.matrix module

amulet.utils.matrix.scale_matrix(sx, sy, sz)[source]

Create a scale matrix from the inputs specified

Parameters
  • sx (float) – The scale in the x axis

  • sy (float) – The scale in the y axis

  • sz (float) – The scale in the z axis

Return type

ndarray

Returns

The 4x4 scale matrix

amulet.utils.matrix.displacement_matrix(x, y, z)[source]

Create a displacement matrix from the inputs specified

Parameters
  • x (float) – The displacement in the x axis

  • y (float) – The displacement in the y axis

  • z (float) – The displacement in the z axis

Return type

ndarray

Returns

The 4x4 displacement matrix

amulet.utils.matrix.rotation_matrix_x(rx)[source]

Create a rotation matrix in the x axis

Parameters

rx (float) – The angle in radians

Return type

ndarray

Returns

The 4x4 rotation matrix

amulet.utils.matrix.rotation_matrix_y(ry)[source]

Create a rotation matrix in the x axis

Parameters

ry (float) – The angle in radians

Return type

ndarray

Returns

The 4x4 rotation matrix

amulet.utils.matrix.rotation_matrix_z(rz)[source]

Create a rotation matrix in the x axis

Parameters

rz (float) – The angle in radians

Return type

ndarray

Returns

The 4x4 rotation matrix

amulet.utils.matrix.rotation_matrix_xy(rx, ry)[source]

Create a rotation matrix from the inputs specified

Parameters
  • rx (float) – The rotation in radians in the x axis

  • ry (float) – The rotation in radians in the y axis

Return type

ndarray

Returns

The 4x4 rotation matrix

amulet.utils.matrix.rotation_matrix_yx(ry, rx)[source]

Create a rotation matrix from the inputs specified

Parameters
  • rx (float) – The rotation in radians in the x axis

  • ry (float) – The rotation in radians in the y axis

Return type

ndarray

Returns

The 4x4 rotation matrix

amulet.utils.matrix.rotation_matrix_xyz(x, y, z)[source]

Create a rotation matrix from the inputs specified

Parameters
  • x (float) – The rotation in radians in the x axis

  • y (float) – The rotation in radians in the y axis

  • z (float) – The rotation in radians in the z axis

Return type

ndarray

Returns

The 4x4 rotation matrix

amulet.utils.matrix.transform_matrix(scale, rotation, displacement, order='xyz')[source]

Create a 4x4 transformation matrix from the scale, rotation and displacement specified.

Parameters
  • scale (Tuple[float, float, float]) – The scale in the x, y and z axis

  • rotation (Tuple[float, float, float]) – The rotation in the x, y and z axis in radians. (axis can be changed using order)

  • displacement (Tuple[float, float, float]) – The displacement in the x, y and z axis

  • order – The order to apply the rotations in.

Returns

The 4x4 transformation matrix of combined scale, rotation and displacement

amulet.utils.matrix.inverse_transform_matrix(scale, rotation, displacement, order='xyz')[source]

Create the inverse of the 4x4 transformation matrix from the scale, rotation and displacement specified. This should be the inverse of transform_matrix

Parameters
  • scale (Tuple[float, float, float]) – The scale in the x, y and z axis

  • rotation (Tuple[float, float, float]) – The rotation in the x, y and z axis (axis can be changed using order)

  • displacement (Tuple[float, float, float]) – The displacement in the x, y and z axis

  • order – The order to apply the rotations in.

Returns

The 4x4 transformation matrix of combined scale, rotation and displacement

amulet.utils.matrix.decompose_transformation_matrix(matrix)[source]

Decompose a 4x4 transformation matrix into scale, rotation and displacement tuples.

Parameters

matrix (ndarray) – The matrix to decompose.

Return type

Tuple[Tuple[float, float, float], Tuple[float, float, float], Tuple[float, float, float]]

Returns

The scale, rotation and displacement.