필터 지우기
필터 지우기

What is MATLAB convention for the direction of normal vector of a triangulated mesh?

조회 수: 19 (최근 30일)
By using the function triangulation, you can have a triangulated mesh. Then by function faceNormal(tr) you can get the normal vector on each triangle. What is the convention for the direction of normal vectors (inward / outward)? How MATLAB manages to make them toward a consistent direction for a nice surface such as a sphere? Is there any predefined (in MATLAB) relationship between the direction of the normal vector and curvature of the surface? Thanks.

답변 (1개)

Soumya Saxena
Soumya Saxena 2017년 1월 27일
편집: Soumya Saxena 2017년 1월 27일
The orientation of the normal is implicitly defined by the ordering of the vertices in a triangle. For all triangulations generated in MATLAB via DELAUNAY, delaunayTriangulation, CONVHULL, BOUNDARY, alphaShape, etc., the ordering follows the right-hand rule. For example, when you view the triangular facets on a convex hull boundary, the vertices are ordered in a counter-clockwise manner and the normal is in the outward direction with respect to the hull. In terms of the right-hand rule, your four fingers curl around in the orientation of the triangle and your thumb indicates the direction of the triangle normal.
The normal vector is obtained from the cross-product of two edges of the triangle.
Please consider the following example:
[x, y, z] = meshgrid(0:1);
x = x(:);
y = y(:);
z = z(:);
tri = convhull(x,y,z);
tr = triangulation(tri, x, y, z);
figure('Color', 'white')
trisurf(tr,'faceColor','cyan')
axis equal;
fn = faceNormal(tr);
P = incenter(tr);
hold on;
quiver3(P(:,1),P(:,2),P(:,3),fn(:,1),fn(:,2),fn(:,3),0.5, 'color','r');
hold off;
% Now flip the ordering of the vertices and the normals will point
% in the opposite direction. We can do this by exchanging any two
% colums of the triangles matrix.
tri = [tri(:,1), tri(:,3), tri(:,2)];
figure('Color', 'white')
tr = triangulation(tri, x, y, z);
trisurf(tr,'faceColor','cyan', 'FaceAlpha',0.5)
axis equal;
fn = faceNormal(tr);
P = incenter(tr);
hold on;
quiver3(P(:,1),P(:,2),P(:,3),fn(:,1),fn(:,2),fn(:,3),0.5, 'color','r');
hold off;
  댓글 수: 1
Patrick Lv
Patrick Lv 2019년 4월 29일
Nice answer. But why the face normals are outward directed before switching columns of tri rathern than inward directed?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by