-
Notifications
You must be signed in to change notification settings - Fork 11
Transfer the point cloud to the target coordinate system #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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".
| 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] |
There was a problem hiding this comment.
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:
| 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] |
在点云操作中,经常需要转换坐标系,所以追加了这个方法