def curvature(face): """ Returns the local curvature of a mesh face, by measuring the angle to the neighbour faces. Arguments: ---------- face : mola.core.Face The face to be measured """ facenormal = normal(face) sumD = 0 vPrev = face.vertices[-1] num_faces = 1 for v in face.vertices: edge = v.getEdgeAdjacentToVertex(vPrev) if edge != None: nbFace = edge.face1 if edge.face1 == face: nbFace = edge.face2 if nbFace != None: num_faces += 1 nbNormal = normal(nbFace) sumD += _vec.distance(nbNormal, facenormal) vPrev = v return sumD / num_faces
def perimeter(face): """ Returns the perimeter of a face as the sum of all the edges' lengths. Arguments: ---------- face : mola.core.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 += _vec.distance(v1, v2) return sum