public void CreateTriangle_returns_triangle_with_given_vertices() { var a = new Vector3(3.141, 2.718, 0.577); var b = new Vector3(1.414, 1.732, 2.236); var c = new Vector3(0.693, 1.202, 0.739); var triangle = Polygon3Utils.CreateTriangle(a, b, c); Expect(triangle.Contours().Count(), Is.EqualTo(1)); var vertices = triangle.Vertices(); Expect(vertices.Count(), Is.EqualTo(3)); Expect(vertices.Select(v => Vector3.Distance(a, v)).Min(), Is.LessThan(_tolerance)); Expect(vertices.Select(v => Vector3.Distance(b, v)).Min(), Is.LessThan(_tolerance)); Expect(vertices.Select(v => Vector3.Distance(c, v)).Min(), Is.LessThan(_tolerance)); }
public static double DistanceTo(this Vector3 @this, IPolysurface surface) { return(Math.Sqrt(surface.Faces.Select(f => Polygon3Utils.Distance2(@this, f.Polygon)).Min())); }