Why does transforming with affine3D yield different result than multiplying with transfomation matrix?

1 visualizzazione (ultimi 30 giorni)
Hi,
I am trying to transform a pointcloud with a transformation matrix on a point-per-point basis.
In the following script I run a pctransform which does indeed shift the pointcloud over a unit of 1.
However, when applying the same transformation matrix on a point per point basis, I dont see any difference in the resulting point cloud.
I cant use pctransform in my final setup since my transformation matrices are non-rigid.
Could anyone point me out what i am doing wrong?
ptCloud1 = pointCloud(rand(10000,3,'single'));
moveRight = [1 0 0 0; ...
0 1 0 0; ...
0 0 1 0; ...
1 0 0 1];
ptCloudRight = pctransform(copy(ptCloud1),affine3d(moveRight));
pcshowpair(ptCloud1,ptCloudRight);
ptCloudRightCreated = pointCloud(transformPoints(copy(ptCloud1), moveRight))
pcshowpair(ptCloud1,ptCloudRightCreated);
function newPoints = transformPoints(ptc, tmatrix)
newPoints = [];
disp(tmatrix)
for i = 1 : ptc.Count
point = [ptc.Location(i,:), 0];
tPoint = point * tmatrix;
newPoints = cat(1, newPoints, tPoint(1:3));
end
end

Risposte (2)

Kin Sung Chan
Kin Sung Chan il 9 Nov 2019
ptCloud = pointCloud(rand(10000,3,'single'));
moveRight = [1 0 0 0; ...
0 1 0 0; ...
0 0 1 0; ...
1 0 0 1];
tform = affine3d(moveRight);
ptCloudRight = pctransform(ptCloud, tform);
figure(1)
pcshowpair(ptCloud, ptCloudRight );
I have no problems translating the point cloud.

Lewis Newton
Lewis Newton il 27 Feb 2020
This appears to have been expanded in the 2019 version, if you check your current help you'll find that it says it must be rigid.
If you update your version, help says this function works for both rigid and non-rigid transforms!

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by