Matlab 2.5D Delaunay三角剖分顶点法线



我正在尝试做我认为在Matlab中称为2.5D Delaunay三角剖分和顶点法线计算。使用delaunayTriangulation类和相关函数,我可以三角测量x,y平面,并获得所需的网格。然而,试图提取表面法线只能得到平面的法线。这很有意义,因为我只向delaunayTriangulation提供了2D数据,但我不知道在这种情况下vertexNormal()函数有什么用处。我错过了什么-我如何提取法线与高度属性的三角网格?

我知道如何使用surform()或类似的函数为网格做到这一点,但我希望这也适用于分散的点,而不必网格化。

说明的工作示例:

% Generate some data
rng(42); % Seed random gen
[X,Y] = meshgrid( 1:100, 1:100 );
k = ones(15)./(15^2);
Z = conv2(rand(size(X)), k, 'same'); % Smooth data to have a nice surface to test with
% Triangulate
DT = delaunayTriangulation(X(:),Y(:));
% DT.vertexNormal are all [0 0 1] (flat surface...) - makes sense.
DT3 = delaunayTriangulation(X(:),Y(:),Z(:));
% DT3.vertexNormal() --> gives error because we now did 3D delaunayTrinagulation and have tetraheders, not triangles. Also makes sense. 
% DT.Points = [DT.Points, Z(:)]; --> Something crazy like trying to add Z points after triangulation gives error, obviously

我明白了,但我会把答案贴在这里供其他需要的人使用。这显然就是triangulation()函数的作用:

% Triangulate 2D
DT = delaunayTriangulation(X(:),Y(:));
% Triangulate 3D ("2.5D")
DT_3D = triangulation( DT.ConnectivityList, X(:), Y(:), Z(:) );
% Calculate vertex normals
vertex_normals = DT_3D.vertexNormal();

相关内容

  • 没有找到相关文章

最新更新