如何确定三角形网格是否凹陷?

时间:2013-04-30 10:06:44

标签: c++ algorithm mesh convex non-convex

给定一个三维三角形网格,我怎样才能知道它是凸面还是凹面?有算法检查吗?如果是这样,定义公差范围以忽略小凹陷将是有用的。

concave and convex illustration

图片来源:http://www.rustycode.com/tutorials/convex.html

2 个答案:

答案 0 :(得分:3)

对于您描述的简单多边形,您可以检查每个顶点的每个内角,并检查角度是否低于180度。如果是这样,就没有凹陷的方式。如果单个顶点超过180°,则它是凹的。

编辑:对于3D网格,同样的想法适用,但你必须在每个顶点测试每个三角形,无论三角形之间的角度是高于还是低于180°

答案 1 :(得分:3)

凸多面体may be defined作为有限数量的半空间的交集。这些半空间实际上是面定义的半空间。

编辑:假设您的网格实际上定义了一个多面体(即有一个“内部”和一个“外部”)

你可以这样做(伪代码):

for each triangle
    p = triangle plane
    n = normal of p (pointing outside)
    d = distance from the origin of p
    //Note: '*' is the dot product.
    //so that X*N + d = 0 is the plane equation
    //if you write a plane equation like (X-P)*n = 0 (where P is any point which lays in the plane), then d = -P*n (it's a scalar).

    for each vertex v in the mesh
         h = v*N + d
         if (h > Tolerance) return NOT CONVEX
         //Notice that when v is a vertex of the triangle from which n and d come from,
         //h is always zero, so the tolerance is required (or you can avoid testing those vertices)
    end
end
return CONVEX