Rotate 3-D Point Cloud Using Rigid Transformation
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alberto Acri
am 20 Dez. 2022
Bearbeitet: Matt J
am 20 Dez. 2022
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;
angle_rad = deg2rad(angle);
rot_matrix = [ cos(angle_rad) sin(angle_rad) 0 0 ; ...
-sin(angle_rad) cos(angle_rad) 0 0 ; ...
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'."
ptCloud = pcread('teapot.ply');
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!
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (2)
Bora Eryilmaz
am 20 Dez. 2022
Bearbeitet: Bora Eryilmaz
am 20 Dez. 2022
- 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 Kommentare
Torsten
am 20 Dez. 2022
Bearbeitet: Torsten
am 20 Dez. 2022
angle = 180;
angle_rad = deg2rad(angle);
rot_matrix = [ cos(angle_rad) -sin(angle_rad) 0 ; ...
sin(angle_rad) cos(angle_rad) 0 ; ...
0 0 1 ];
ptCloud = pcread('teapot.ply')
gc = mean(ptCloud.Location,1)
figure
pcshow(ptCloud)
xlabel('X')
ylabel('Y')
zlabel('Z')
gc = mean(ptCloud.Location,1)
ptCloudOut = ptCloud.Location - gc;
ptCloudOut = (rot_matrix*ptCloudOut.').';
ptCloudOut = ptCloudOut + gc;
gc_transformed = mean(ptCloudOut,1)
figure
pcshow(ptCloudOut)
xlabel('X')
ylabel('Y')
zlabel('Z')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Point Cloud Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

