/// <summary> /// Calculates the size of the area that's both in the specified face and closer to the specified vertex than any other vertex. /// </summary> public static double AreaSharedByVertexAndFace(IPolyhedron surface, Vertex vertex, Face face) { var vertexPosition = vertex.Position; var faces = surface.FacesOf(vertex); var edges = surface.EdgesOf(vertex); var index = faces.IndexOf(face); if (!faces.Contains(face)) { return(0.0); } var midpointOfFace = face.Center(); var previousEdge = edges.AtCyclicIndex(index - 1); var midpointOfPreviousEdge = BisectionPoint(surface, previousEdge); var nextEdge = edges.AtCyclicIndex(index); var midpointOfNextEdge = BisectionPoint(surface, nextEdge); var crossProductOfFirstSegment = Vector.CrossProduct(midpointOfPreviousEdge - vertexPosition, midpointOfFace - vertexPosition); var areaOfFirstSegment = Vector.ScalarProduct(crossProductOfFirstSegment, midpointOfFace.Normalize()) / 2; var crossProductOfSecondSegment = Vector.CrossProduct(midpointOfFace - vertexPosition, midpointOfNextEdge - vertexPosition); var areaOfSecondSegment = Vector.ScalarProduct(crossProductOfSecondSegment, midpointOfFace.Normalize()) / 2; return(areaOfFirstSegment + areaOfSecondSegment); }