Problem: Find the smallest enclosing circle of a planar set of points
G# uses a randomized incremental algorithm to compute the smallest circle that encloses a planar set of points. With an expected running time of O(n), it is very fast.
Solution using G#
- public static void Minidisk()
- {
- miniDisk.InitialPoints = SamplePoints.RandomInRectangle(100, 1, 1);
- //Compute the smallest enclosing circle
- Circle smallestEnclosingCircle = miniDisk.ComputeCircle();
- //Visualize
- sc.PointSize = 0.01;
- sc.Add(smallestEnclosingCircle, cLayer);
- sc.Add(miniDisk.InitialPoints, pLayer);
- sc.WriteDxf(@"c:\minidisk.dxf");
- }

