/// <summary> /// Constructs a table of the area of intersection between each face and the vertices around it. /// </summary> public static double[][] AreaInEachVertex(IPolyhedron surface) { var allAreas = new double[surface.Faces.Count][]; foreach (var face in surface.Faces) { var vertices = face.Vertices; var areas = vertices.Select(vertex => PolyhedronUtilities.AreaSharedByVertexAndFace(surface, vertex, face)).ToArray(); allAreas[surface.IndexOf(face)] = areas; } return(allAreas); }
public void AreaSharedByVertexAndFace_OnACube_ShouldProduceTheCorrectValues (IPolyhedron polyhedron) { // Fixture setup var vertices = polyhedron.Vertices; var faces = polyhedron.Faces; var expected = Enumerable.Repeat(1.0, 24).Concat(Enumerable.Repeat(0.0, 24)).ToList(); // Exercise system var actual = vertices.SelectMany(vertex => faces.Select(face => PolyhedronUtilities.AreaSharedByVertexAndFace(polyhedron, vertex, face))).ToList(); // Verify outcome TestUtilities.WriteExpectedAndActual(expected, actual); Assert.True(TestUtilities.UnorderedEquals(expected, actual)); // Teardown }