align_to_axis#
- align_to_axis(coordinates, weights=None, axis=2, flip=False, eigenvector_index=0)[source]#
Calculate a rotation matrix that aligns the principal axis of a point cloud with a specified coordinate axis.
- Parameters:
- coordinatesNDArray
Array of 3D coordinates with shape (n, 3) representing the point cloud.
- weightsNDArray
Coordinate weighting factors with shape (n,).
- axisint, optional
The target axis to align with, defaults to 2 (z-axis).
- flipbool, optional
Whether to align with the negative direction of the axis, default is False.
- eigenvector_indexint, optional
Index of eigenvector to select, sorted by descending eigenvalues. 0 = largest eigenvalue (most variance), 1 = second largest, etc. Default is 0 (primary principal component).
- Returns:
- NDArray
3x3 rotation matrix that aligns the principal component of the coordinates with the specified axis.