Traslate and Rotate a point cloud

14 次查看(过去 30 天)
Alberto Acri
Alberto Acri 2022-11-28
评论: Jonas 2022-11-29
Hi! I have a point cloud (.txt file with R rows and 3 columns).
I want to translate the point cloud from the center of gravity G = [100, 100, 100] to a point A = [0,0,0].
And possibly also rotate it by a certain angle.

回答(1 个)

Jonas
Jonas 2022-11-28
if you have a matrix nx3, with each row being one set of point corrdinates you can translate first and rotate afterwards using subtraction
points=[1 0 0; 2 0 0; 3 0 0; 4 0 0]+[100 80 50]; % one point per row
tiledlayout(2,1);
nexttile()
scatter3(points(:,1),points(:,2),points(:,3))
translateBy=[100 50 30]; % row vector
% in degree
aroundX=0;
aroundY=90;
aroundZ=90;
% first matrix flip because rotation matrix want one ppoint per column
% second matrix flip
rotPoints=(rotz(aroundZ)*roty(aroundY)*rotx(aroundX)*(points-translateBy)')'
rotPoints = 4×3
-30 20 -1 -30 20 -2 -30 20 -3 -30 20 -4
nexttile
scatter3(rotPoints(:,1),rotPoints(:,2),rotPoints(:,3))
  2 个评论
Alberto Acri
Alberto Acri 2022-11-28
编辑:Alberto Acri 2022-11-28
Thank you for your answer @Jonas.
But how can I do it if I want to translate the point cloud from the center of gravity G = [100, 140, 50] to a point A = [0,0,0]?
I want to get something like this:
Jonas
Jonas 2022-11-29
if you have apoint cloud with center of gravity [100, 140, 50] and you want to move the center of gravity to [0,0,0], then just subtract the given coordinates before rotation.
-> set translateBy to [100, 140, 50]
of course your center of gravity moves with the points, so G would equal A afterwards

请先登录,再进行评论。

类别

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!

Translated by