Skip to content

Conversation

@raymondwm
Copy link

在点云操作中,经常需要转换坐标系,所以追加了这个方法

Copy link

@windsurf-bot windsurf-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 To request another review, post a new comment with "/windsurf-review".

Comment on lines 841 to 853
def transform(self, transform_matrix: npt.NDArray) -> None:
"""Transfer the point cloud to the target coordinate system
:param transform_matrix: 4*4 matrix
"""
xyz_pcd = self.numpy(('x', 'y', 'z'))
points_quantic = np.column_stack(
(xyz_pcd, np.ones(xyz_pcd.shape[0])))
transformed_points = np.dot(transform_matrix, points_quantic.T).T
self.pc_data['x'] = transformed_points[:, 0]
self.pc_data['y'] = transformed_points[:, 1]
self.pc_data['z'] = transformed_points[:, 2]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transform_matrix parameter should be validated to ensure it's a 4x4 matrix before performing the transformation. Consider adding a shape check:

Suggested change
def transform(self, transform_matrix: npt.NDArray) -> None:
"""Transfer the point cloud to the target coordinate system
:param transform_matrix: 4*4 matrix
"""
xyz_pcd = self.numpy(('x', 'y', 'z'))
points_quantic = np.column_stack(
(xyz_pcd, np.ones(xyz_pcd.shape[0])))
transformed_points = np.dot(transform_matrix, points_quantic.T).T
self.pc_data['x'] = transformed_points[:, 0]
self.pc_data['y'] = transformed_points[:, 1]
self.pc_data['z'] = transformed_points[:, 2]
def transform(self, transform_matrix: npt.NDArray) -> None:
"""Transfer the point cloud to the target coordinate system
:param transform_matrix: 4*4 matrix
"""
if transform_matrix.shape != (4, 4):
raise ValueError(f"Expected 4x4 transformation matrix, got {transform_matrix.shape}")
xyz_pcd = self.numpy(('x', 'y', 'z'))
points_quantic = np.column_stack(
(xyz_pcd, np.ones(xyz_pcd.shape[0])))
transformed_points = np.dot(transform_matrix, points_quantic.T).T
self.pc_data['x'] = transformed_points[:, 0]
self.pc_data['y'] = transformed_points[:, 1]
self.pc_data['z'] = transformed_points[:, 2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant