【发布时间】:2021-05-27 03:39:00
【问题描述】:
我正在尝试在 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
【问题讨论】: