MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / transform_points

Function transform_points

benchmark/models/loger/utils/visual_util.py:557–579  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

555
556
557def 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
582def compute_camera_faces(cone_shape: trimesh.Trimesh) -> np.ndarray:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected