Transfer the point cloud to the target coordinate system#50
Open
raymondwm wants to merge 2 commits intoMapIV:mainfrom
Open
Transfer the point cloud to the target coordinate system#50raymondwm wants to merge 2 commits intoMapIV:mainfrom
raymondwm wants to merge 2 commits intoMapIV:mainfrom
Conversation
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] |
There was a problem hiding this comment.
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
在点云操作中,经常需要转换坐标系,所以追加了这个方法