blenderproc.python.utility.MathUtility module

A collection of math functions.

class blenderproc.python.utility.MathUtility.MathUtility[source]

Bases: object

Math utility class

static build_coordinate_frame_changing_transformation_matrix(destination_frame)[source]

Builds a transformation matrix that switches the coordinate frame.

Parameters:

destination_frame (List[str]) – An array containing three elements, describing each axis of the destination coordinate frame based on the axes of the source frame. Available: [“X”, “Y”, “Z”, “-X”, “-Y”, “-Z”].

Return type:

ndarray

Returns:

The transformation matrix

blenderproc.python.utility.MathUtility.build_transformation_mat(translation, rotation)[source]

Build a transformation matrix from translation and rotation parts.

Parameters:
  • translation (Union[ndarray, List[float], Vector]) – A (3,) vector representing the translation part.

  • rotation (Union[ndarray, List[List[float]], Matrix]) – A 3x3 rotation matrix or Euler angles of shape (3,).

Return type:

ndarray

Returns:

The 4x4 transformation matrix.

blenderproc.python.utility.MathUtility.change_coordinate_frame_of_point(point, new_frame)[source]

Transforms the given point into another coordinate frame.

Example: [1, 2, 3] and [“X”, “-Z”, “Y”] => [1, -3, 2]

Parameters:
  • point (Union[ndarray, List[float], Vector]) – The point to convert in form of a np.ndarray, list or mathutils.Vector.

  • new_frame (List[str]) – An array containing three elements, describing each axis of the new coordinate frame based on the axes of the current frame. Available: [“X”, “Y”, “Z”, “-X”, “-Y”, “-Z”].

Return type:

ndarray

Returns:

The converted point also in form of a np.ndarray

blenderproc.python.utility.MathUtility.change_source_coordinate_frame_of_transformation_matrix(matrix, new_frame)[source]

Changes the coordinate frame the given transformation matrix is mapping from.

Given a matrix $T_A^B$ that maps from A to B, this function can be used to change the axes of A into A’ and therefore end up with $T_A’^B$.

Parameters:
  • matrix (Union[ndarray, Matrix]) – The matrix to convert in form of a np.ndarray or mathutils.Matrix

  • new_frame (list) – An array containing three elements, describing each axis of the new coordinate frame based on the axes of the current frame. Available: [“X”, “Y”, “Z”, “-X”, “-Y”, “-Z”].

Return type:

ndarray

Returns:

The converted matrix is in form of a np.ndarray

blenderproc.python.utility.MathUtility.change_target_coordinate_frame_of_transformation_matrix(matrix, new_frame)[source]

Changes the coordinate frame the given transformation matrix is mapping to.

Given a matrix $T_A^B$ that maps from A to B, this function can be used to change the axes of B into B’ and therefore end up with $T_A^B’$.

Parameters:
  • matrix (Union[ndarray, Matrix]) – The matrix to convert in form of a np.ndarray or mathutils.Matrix

  • new_frame (List[str]) – An array containing three elements, describing each axis of the new coordinate frame based on the axes of the current frame. Available: [“X”, “Y”, “Z”, “-X”, “-Y”, “-Z”].

Return type:

ndarray

Returns:

The converted matrix is in form of a np.ndarray