由于您拥有 3 x N 点云,假设它的名称为 mat。那么我建议采取以下方法:
% Constructing the Point Cloud and Data Structure
ptCloud = pointCloud(mat);
% Normal Esitmation (3 is simply tthe number of points used for local plane fitting)
normals = pcnormals(ptCloud,3);
此时,您的法线以 (3N) x 3 矩阵的形式计算。您可以通过
将其添加为点云的属性
ptCloud.Normal = normals;
为了将其可视化,可以执行以下操作:
step_size = 10;
x = ptCloud.Location(1:step_size:end,1);
y = ptCloud.Location(1:step_size:end,2);
z = ptCloud.Location(1:step_size:end,3);
u = ptCloud.Normal(1:step_size:end,1);
v = ptCloud.Normal(1:step_size:end,2);
w = ptCloud.Normal(1:step_size:end,3);
% plot
figure;
hold on
% plot the point cloud
pcshow(ptCloud);
% plot the normal arrows
quiver3(x,y,z,u,v,w);
hold off
最后一条评论:与简单地绘制点矩阵相比,通过pointCloud 函数创建点云提供了更优化的可视化效果。