mymesh.register.AxisAlignPoints#

mymesh.register.AxisAlignPoints(points, axis_order=[2, 1, 0], center=None, return_transformed=True, return_transform=False, method='MVBB')[source]#

Align an point cloud to the x, y, z axes. This works by identifying the minimum volume bounding box (see :func:~`mymesh.utils.MVBB`) and aligning that box to the principal axes, so point clouds representing rounded objects with ambiguous orientation may be oriented seemingly-arbitrarily. The center of the object (defined as the centroid of the MVBB) will be preserved in the alignment unless a different center is specified.

Parameters:
  • points (array_like) – Array of point coordinates (shape=(n,3))

  • axis_order (array_like, optional) – Orientation of the aligned object in terms of the lengths of each side of the object, by default [0,1,2]. The first axis will correspond to the shortest side of the object and the last index to the longest side. For example, with [0,1,2], the longest side will be aligned with the z (2) axis, and the shortest will be aligned with the x (0) axis. Must be a combination of 0, 1, and 2.

  • center (array_like or NoneType, optional) – If provided, coordinates [x,y,z] of where to place to place the center of the bounding box of the object after transformation. If None, the center of the oriented points will be the center of the original points, by default None.

  • return_transform (bool, optional) – Option to return the transformation matrix as well as the transformed point cloud, by default False

Returns:

  • transformed (np.ndarray) – Array of point coordinates transformed to be aligned to the axes

  • transform (np.ndarray, optional) – Affine transformation matrix (shape=(4,4)) to transform points to transformed (transformed=(transform@points.T).T). Only returned if return_transform = True.