Alingning a 3D point-cloud along its centerline
2 views (last 30 days)
Show older comments
Hi,
I am trying to allign some large 3D point-clouds from scanned tunnels/pipes along their centerline. Based on different info I collected on this forum and eslewhere, I:
1 - calculate the direction/equation of the centerline
A=[x(:),y(:),z(:)]; % Point cloud
m=mean(A,1).';
Atemp=A-m.';
% Singular value decomposition of matrix A, such that A = U*S*V'
[~,~,V]=svd(Atemp,0);
d=V(:,1); % Direction vector of the centerline
2 - calculate the rotation matrix needed to align the direction vector with a reference vector
rot=vrrotvec(d,[0;0;1]);
r=[rot(1),rot(2),rot(3)]; % Rotation vector
rot(4)=rot(4)*180/pi(); % Rotation in deg - for info
R=rotationVectorToMatrix(r);
A_rot=A*R;
While testing these lines on a cloud almost aligned, I end up with a cloud rotated in a random direction (A_rot), so I clearly missed out on something here.
Would anybody have an idea about what is wrong here?
Thanks in advance :)
1 Comment
darova
on 13 Feb 2020
Can you be more specific? Can you attach the data
Please show the result picture you want to achieve
Answers (0)
See Also
Categories
Find more on Coordinate Transformations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!