public void BisectionPoint_OfTheEdgeOfACube_ShouldBeEquidistantFromBothEnds (IPolyhedron polyhedron) { // Fixture setup // Exercise system var points = polyhedron.Edges.Select(edge => PolyhedronUtilities.BisectionPoint(polyhedron, edge)).ToList(); // Verify outcome var expected = polyhedron.Edges.Select((edge, i) => (edge.A.Position - points[i]).Norm()).ToList(); var actual = polyhedron.Edges.Select((edge, i) => (edge.B.Position - points[i]).Norm()).ToList(); TestUtilities.WriteExpectedAndActual(expected, actual); Assert.True(Enumerable.SequenceEqual(expected, actual)); // Teardown }
/// <summary> /// Constructs a table of the distances from each vertex to the bisectors running across each neighbouring edge. /// </summary> public static double[][] HalfEdgeLengths(IPolyhedron surface) { var halfLengthsTable = new double[surface.Vertices.Count][]; foreach (var vertex in surface.Vertices) { var edges = surface.EdgesOf(vertex); var lengths = new List <double>(); foreach (var edge in edges) { var neighbour = edge.Vertices().First(v => v != vertex); var bisectionPoint = PolyhedronUtilities.BisectionPoint(surface, edge); var length = (neighbour.Position - bisectionPoint).Norm(); //TODO: This is planar distance, not geodesic. lengths.Add(length); } halfLengthsTable[surface.IndexOf(vertex)] = lengths.ToArray(); } return(halfLengthsTable); }