Applies a 4x4 transformation to a set of points. Args: transformation (np.ndarray): Transformation matrix. points (np.ndarray): Points to be transformed. dim (int, optional): Dimension for reshaping the result. Returns: np.ndarray: Transformed points.
(transformation: np.ndarray, points: np.ndarray, dim: int = None)
| 555 | |
| 556 | |
| 557 | def transform_points(transformation: np.ndarray, points: np.ndarray, dim: int = None) -> np.ndarray: |
| 558 | """ |
| 559 | Applies a 4x4 transformation to a set of points. |
| 560 | |
| 561 | Args: |
| 562 | transformation (np.ndarray): Transformation matrix. |
| 563 | points (np.ndarray): Points to be transformed. |
| 564 | dim (int, optional): Dimension for reshaping the result. |
| 565 | |
| 566 | Returns: |
| 567 | np.ndarray: Transformed points. |
| 568 | """ |
| 569 | points = np.asarray(points) |
| 570 | initial_shape = points.shape[:-1] |
| 571 | dim = dim or points.shape[-1] |
| 572 | |
| 573 | # Apply transformation |
| 574 | transformation = transformation.swapaxes(-1, -2) # Transpose the transformation matrix |
| 575 | points = points @ transformation[..., :-1, :] + transformation[..., -1:, :] |
| 576 | |
| 577 | # Reshape the result |
| 578 | result = points[..., :dim].reshape(*initial_shape, dim) |
| 579 | return result |
| 580 | |
| 581 | |
| 582 | def compute_camera_faces(cone_shape: trimesh.Trimesh) -> np.ndarray: |
no outgoing calls
no test coverage detected