Problem: Find a rastered Delaunay triangulation of a projectable set of points
Consider the Delaunay triangulation of the previous example. Due to the random point generation on the surface of the starfish, the triangles also have a random shape.
You can easily re-triangulate the existing triangulation over an arbitrary rectangular raster. Use this feature not only to rasterize your point data but also to reduce the number of triangles.
Solution using D#
- public static void DelaunayRasteredExample()
- {
- // Create a sample point set
- PointSet ps = SamplePoints.SupershapeStarfish(10000);
- // Instantiate a delaunay triangulation
- // Assign the point set to triangulate
- dt.TriangulationPoints = ps;
- // Triangulate the point set
- dt.Triangulate();
- // You may add points to the existing triangulation
- // Rasterize the current triangulation in over 0.02x0.02-raster
- dt.RasterizeCurrentTriangulation(0.02, 0.02);
- // Get the triangulation
- List<Triangle> triangles = dt.GetTriangles();
- // visualize: ---------------------------------------------------
- // Make a scene
- // Set the point style
- sc.PointDisplayMode = 0;
- sc.PointSize = 0;
- // Make a layer for the triangles
- // Make a layer for the triangulation points
- // Add the triangles and the triangulation points to the scene
- sc.Add(triangles, tLayer);
- sc.Add(dt.TriangulationPoints, pLayer);
- // Output the scene as dxf
- sc.WriteDxf(@"c:\delaunay_rastered.dxf");
- }


