【问题标题】:Matlab 2.5D Delaunay triangulation vertex normalsMatlab 2.5D Delaunay三角剖分顶点法线
【发布时间】: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

【问题讨论】:

    标签: matlab mesh delaunay


    【解决方案1】:

    我想通了,但会在这里为有需要的人发布答案。这显然是 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();
    

    【讨论】:

      猜你喜欢
      • 2020-05-06
      • 2020-08-05
      • 1970-01-01
      • 2015-01-07
      • 2017-07-15
      • 2020-10-20
      • 2014-07-29
      • 2019-04-18
      • 1970-01-01
      相关资源
      最近更新 更多