Point cloud sequential transformation

Hi everyone,
I'm trying to apply two transformations to a point cloud, a translation A and then a rotation B. My issue is that the transformation matrix I get when using pcregistericp seems to be the opposite of what I expected (I get A*B instead of B*A). I'm not sure what the issue is, or if I'm misunderstanding the order of transformations in linear algebra.
xyzPoints=[];
for x=0:0.1:1
for y=0:0.2:2
z=x^2+y^3;
xyzPoints=[xyzPoints;x y z];
end
end
ptCloud100 = pointCloud(xyzPoints);
%translation
A = [1 0 0 0; ...
0 1 0 0; ...
0 0 1 0; ...
2 4 5 1];
tform = affine3d(A);
ptCloudOuttrans = pctransform(ptCloud100,tform);
%rotation
theta=deg2rad(70);
B = [cos(theta) 0 sin(theta) 0; ...
0 1 0 0; ...
-sin(theta) 0 cos(theta) 0; ...
0 0 0 1];
tform = affine3d(B);
ptCloudOutrot = pctransform(ptCloudOuttrans,tform);
%ICP
[tform_inv,movingReg] = pcregistericp(ptCloudOutrot,ptCloud100,'Extrapolate',true,'MaxIterations',50);
t=invert(tform_inv);
disp(t.T);
%What I expected it to match
disp(B*A);
%what it matches
disp(A*B);

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 5월 19일

0 개 추천

The answer is simple. MATLAB's accuracy is not absolute and thus, you have gotten difference. You can test this exercise:
theta=deg2rad(90);
...
B*A
A*B
...
Good luck.

댓글 수: 1

Daniela Moreno
Daniela Moreno 2021년 5월 19일
Thank you for your response, but I'm not sure I understand your answer.
The reason why I'm confused it's because t.T (specially in the last row) seems to correspond much closer to A*B than to B*A which is what I would have expected because of B being applied after A.
I then changed the order of the transformations and got the opposite, so I'm not sure if I'm misunderstanding something about linear algebra or the transformation functions.

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

카테고리

제품

릴리스

R2020a

질문:

2021년 5월 19일

댓글:

2021년 5월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by