private static Point[][] GetPolygons(VoronoiResult2D voronoi, Vector offset) { Point[][] retVal = new Point[voronoi.ControlPoints.Length][]; for (int cntr = 0; cntr < voronoi.ControlPoints.Length; cntr++) { retVal[cntr] = voronoi.GetPolygon(cntr, 1). // don't need to worry about ray length, they are all segments Select(o => o + offset). // shifting the points by offset ToArray(); } return(retVal); }
private static double[] AnalyzeVoronoiCellSizes(VoronoiResult2D voronoi, ISOMInput[][] imagesByNode) { // Calculate area, density of each node var sizes = Enumerable.Range(0, voronoi.ControlPoints.Length). Select(o => { double area = Math2D.GetAreaPolygon(voronoi.GetPolygon(o, 1)); // there are no rays double imageCount = imagesByNode[o].Length.ToDouble(); return(new { ImagesCount = imageCount, Area = area, Density = imageCount / area, }); }). ToArray(); // Don't let any node have an area smaller than this double minArea = sizes.Min(o => o.Area) * .2; // Find the node with the largest density. This is the density to use when drawing all cells var largestDensity = sizes. OrderByDescending(o => o.Density). First(); return(sizes.Select(o => { // Figure out how much area it would take using the highest density double area = o.ImagesCount / largestDensity.Density; if (area < minArea) { area = minArea; } return area; }). ToArray()); }
private static double[] AnalyzeVoronoiCellSizes(VoronoiResult2D voronoi, ISOMInput[][] imagesByNode) { // Calculate area, density of each node var sizes = Enumerable.Range(0, voronoi.ControlPoints.Length). Select(o => { double area = Math2D.GetAreaPolygon(voronoi.GetPolygon(o, 1)); // there are no rays double imageCount = imagesByNode[o].Length.ToDouble(); return new { ImagesCount = imageCount, Area = area, Density = imageCount / area, }; }). ToArray(); // Don't let any node have an area smaller than this double minArea = sizes.Min(o => o.Area) * .2; // Find the node with the largest density. This is the density to use when drawing all cells var largestDensity = sizes. OrderByDescending(o => o.Density). First(); return sizes.Select(o => { // Figure out how much area it would take using the highest density double area = o.ImagesCount / largestDensity.Density; if (area < minArea) { area = minArea; } return area; }). ToArray(); }
private static Point[][] GetPolygons(VoronoiResult2D voronoi, Vector offset) { Point[][] retVal = new Point[voronoi.ControlPoints.Length][]; for (int cntr = 0; cntr < voronoi.ControlPoints.Length; cntr++) { retVal[cntr] = voronoi.GetPolygon(cntr, 1). // don't need to worry about ray length, they are all segments Select(o => o + offset). // shifting the points by offset ToArray(); } return retVal; }