Problem: Rasterize scattered point data
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 by interpolating the existing triangulation. Use this feature to rasterize scattered point data or to reduce the number of triangulation points.
Solution using G#
- 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");
- }


