Beispiel #1
0
        public static void SelfIntersectionTest()
        {
            var  pline = PolyLine.Rectangle(2, 2);
            bool test  = pline.IsSelfIntersectingXY();

            Core.Print(test.ToString());
        }
Beispiel #2
0
        private void VoronoiButton_Click(object sender, RoutedEventArgs e)
        {
            Random rng = null;

            if (VoronoiSeedBox.Text.IsNumeric())
            {
                int seed = int.Parse(VoronoiSeedBox.Text);
                rng = new Random(seed);
            }
            else
            {
                rng = new Random();
            }

            BoundingBox box = new BoundingBox(0, 10, -10, 0, 0, 0);

            int size = 500;

            Geometry.Vector[]             points   = box.RandomPointsInside(rng, size);
            VertexCollection              verts    = new VertexCollection(points);
            MeshFaceCollection            faces    = Mesh.DelaunayTriangulationXY(verts, null, box, false);
            Dictionary <Vertex, MeshFace> voronoi  = Mesh.VoronoiFromDelaunay(verts, faces);
            MeshFaceCollection            outFaces = new MeshFaceCollection(voronoi.Values);
            PolyLine rect = PolyLine.Rectangle(0, -10, 10, 0);

            outFaces = outFaces.TrimToPolygonXY(rect.Vertices);
            outFaces = outFaces.TrimToPolygonXY(rect.Vertices); //Test duplicate edges
            VertexGeometryCollection geometry = new VertexGeometryCollection(outFaces.ExtractFaceBoundaries());

            //ShapeCollection geometry = faces.ExtractFaceBoundaries();
            geometry.Add(new Cloud(verts.ExtractPoints()));
            VoronoiCanvas.Geometry = geometry;
        }