示例#1
0
def face_curvature(face):
    """
    Returns the local curvature of a mesh face, by measuring the angle to the neighbour faces.

    Arguments:
    ----------
    face : mola.Face
        The face to be measured
    """
    facenormal = face_normal(face)
    sumD = 0
    vPrev = face.vertices[-1]
    num_faces = 1
    for v in face.vertices:
        edge = v.edge_adjacent_to_vertex(vPrev)
        if edge != None:
            nbFace = edge.face1
            if edge.face1 == face:
                nbFace = edge.face2
            if nbFace != None:
                num_faces += 1
                nbNormal = face_normal(nbFace)
                sumD += utils_vertex.vertex_distance(nbNormal, facenormal)
        vPrev = v
    return sumD / num_faces
示例#2
0
 def perimeter(self):
     """
     Returns the perimeter of the face as the sum of all the edges' lengths.
     """
     sum = 0
     for i in range(len(self.vertices)):
         v1 = self.vertices[i]
         v2 = self.vertices[(i + 1) % len(self.vertices)]
         sum += utils_vertex.vertex_distance(v1,v2)
     return sum
示例#3
0
def face_perimeter(face):
    """
    Returns the perimeter of a face as the sum of all the edges' lengths.

    Arguments:
    ----------
    face : mola.Face
            The face to be measured
    """
    sum = 0
    for i in range(len(face.vertices)):
        v1 = face.vertices[i]
        v2 = face.vertices[(i + 1) % len(face.vertices)]
        sum += utils_vertex.vertex_distance(v1, v2)
    return sum
示例#4
0
 def curvature(self):
     """
     Returns the local curvature of a mesh face, by measuring the angle to the neighbour faces.
     """
     facenormal = self.normal()
     sumD = 0
     vPrev = self.vertices[-1]
     num_faces = 1
     for v in self.vertices:
         edge = v.edge_adjacent_to_vertex(vPrev)
         if edge != None:
             nbFace = edge.face1
             if edge.face1 == self:
                 nbFace = edge.face2
             if nbFace != None:
                 num_faces += 1
                 nbNormal = utils_face.face_normal(nbFace)
                 sumD += utils_vertex.vertex_distance(nbNormal,facenormal)
         vPrev = v
     return sumD / num_faces