# Rotate 3-D Point Cloud Using Rigid Transformation

조회 수: 40 (최근 30일)
Alberto Acri . 2022년 12월 20일
편집: Matt J . 2022년 12월 20일
Hi! I need to rotate a point cloud (or .txt file of the type rx3) by a certain angle theta with respect to the x-axis (or y- or z-axis) while keeping its center of gravity G (already calculated) fixed.
I am using the rotation matrix but I am unclear how to keep the center of gravity fixed and rotate only with respect to a given axis.
angle = 180;
0 0 1 0 ; ...
0 0 0 1 ];
I had initially tried using this code taken from this link but MatLab reports this error: "Unrecognized function or variable 'rigidtform3d'."
figure
pcshow(ptCloud)
xlabel('X')
ylabel('Y')
zlabel('Z')
rotationAngles = [0 0 45];
translation = [0 0 0];
tform = rigidtform3d(rotationAngles,translation)
ptCloudOut = pctransform(ptCloud,tform);
figure
pcshow(ptCloudOut)
xlabel('X')
ylabel('Y')
zlabel('Z')
Thanks to those who can answer me!
p.s. Otherwise if someone can send me this function ("rigidtform3d") since it's like I don't have it!

댓글을 달려면 로그인하십시오.

### 채택된 답변

Matt J 2022년 12월 20일
편집: Matt J 님. 2022년 12월 20일
xyz=AxelRot(ptCloud.Location',angle, axisVector, mean(ptCloud.Location,1) )';
ptCouldOut=pointCloud(xyz);

댓글을 달려면 로그인하십시오.

### 추가 답변 (2개)

Bora Eryilmaz 2022년 12월 20일
편집: Bora Eryilmaz 님. 2022년 12월 20일
• First translate the point cloud to the origin using a translation of -G.
• Rotate the point cloud around an axis.
• Translate it back to its center of gravity using a translation of G.
##### 댓글 수: 0이전 댓글 -1개 표시이전 댓글 -1개 숨기기

댓글을 달려면 로그인하십시오.

Torsten 2022년 12월 20일
편집: Torsten 님. 2022년 12월 20일
angle = 180;
0 0 1 ];
ptCloud =
pointCloud with properties: Location: [41472×3 single] Count: 41472 XLimits: [-3 3.4340] YLimits: [-2 2] ZLimits: [0 3.1500] Color: [] Normal: [] Intensity: []
gc = mean(ptCloud.Location,1)
gc = 1×3
0.0372 0.0000 1.7251
figure
pcshow(ptCloud)
xlabel('X')
ylabel('Y')
zlabel('Z') gc = mean(ptCloud.Location,1)
gc = 1×3
0.0372 0.0000 1.7251
ptCloudOut = ptCloud.Location - gc;
ptCloudOut = (rot_matrix*ptCloudOut.').';
ptCloudOut = ptCloudOut + gc;
gc_transformed = mean(ptCloudOut,1)
gc_transformed = 1×3
0.0372 -0.0000 1.7251
figure
pcshow(ptCloudOut)
xlabel('X')
ylabel('Y')
zlabel('Z') 댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!