简体   繁体   English

这是3D立体凹面还是凸面的边缘?

[英]Is this Edge of a 3D solid Concave or Convex?

Given a 3D solid model and an edge, I am testing whether that edge is concave or convex. 给定3D实体模型和边缘,我正在测试该边缘是凹面还是凸面。

What is the best way to do this? 做这个的最好方式是什么? I'd like to minimize the assumptions regarding the input geometry. 我想最小化关于输入几何形状的假设。 My first pass at the problem takes the average of the vertices of the two adjacent faces to generate center points, offsets one of those points by the face normal at that point, and tests whether the offset point is closer or farther to the opposing face than the original. 我对问题的第一遍是获取两个相邻面的顶点的平均值以生成中心点,然后用该点处的面法线偏移这些点中的一个,然后测试偏移点是否比相对的面更接近或更远原本的。 This works for pairs of simple faces, approximately the same size. 这适用于大约相同大小的成对的简单面孔。 It fails, for example, with small faces far from the center of larger faces. 例如,当小脸远离大脸中心时,它会失败。

I'm doing this in Revit, but I imagine the problem is the same in Rhino, Catia, any solid modeler. 我正在Revit中进行此操作,但我想问题出在任何实体建模师Rhino,Catia上也是一样。 From the edge I can extract the adjacent faces. 我可以从边缘提取相邻的面。 I know the faces are oriented correctly such that the normals point outward. 我知道这些面孔的方向正确,因此法线指向外部。 I can project 3D points to the faces, calculate normals of the faces at those points, etc. 我可以将3D点投影到人脸,计算这些点处人脸的法线,等等。

Here's the code for the naive version: 这是朴素版本的代码:

  public static Boolean AreFacesConcave(Face face_0, Face face_1, Document doc)
    {
        UV uvMid_0 = VertexAverageUV( face_0 ); //3D average of the vertices
        UV uvMid_1 = VertexAverageUV( face_1 ); // approximates the center of the face

        XYZ pt_0 = face_0.Evaluate(uvMid_0);
        XYZ pt_1 = face_1.Evaluate(uvMid_1);

        // normals at those points
        XYZ normal_0 = face_0.ComputeNormal(uvMid_0);
        XYZ normal_1 = face_1.ComputeNormal(uvMid_1);

        // third point, offset from face 2 by normal
        XYZ pt_2 = pt_1.Add(normal_1.Normalize());


        Double d0 = pt_0.DistanceTo(pt_1);
        Double d1 = pt_0.DistanceTo(pt_2);

        return (d1 < d0);

    }

If you know that normal vectors always are outward, get two points A and B inside two adjacent faces (either mean of three non-collinear vertices or your 'center points'). 如果知道法线向量总是向外,则在两个相邻的面内得到两个点A和B(三个非共线顶点的平均值或您的“中心点”)。

Then check the sign of dot (scalar) product of vectors AB and nA (normal to the face containing point A). 然后检查矢量AB和nA的点(标量)乘积的符号(垂直于包含点A的面)。

 Result = DotProduct(AB, nA)

Negative sign denotes 'convex' edge, positive - 'concave' one. 负号表示“凸”边,正号表示“凹”边。

2D example: nA is outward normal, D-edge for CDF is concave, D-edge for CDE is convex 2D示例:nA是向外法线,CDF的D边缘是凹面,CDE的D边缘是凸面

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM