private static double GetProximityDistance(Point[] l1, Point[] l2) { var d1 = ProximityDistanceEstimate.Compute(l1); var d2 = ProximityDistanceEstimate.Compute(l2); return(Math.Min(d1, d2)); }
public static SubdivisionResult Subdivide(Point[] l1, Point[] l2) { // create a polygon from l1, l2: we assume here that l1 and l2 have the same direction var polygon = l1.Concat(l2.Reverse()).ToArray(); var filteredPoints = TwoLinesMedialAxis.Compute(l1, l2, polygon); // connect the extreme points with a long path (dijkstra algorithm) var proximityDistance = ProximityDistanceEstimate.Compute(filteredPoints); var path = PointsToPolylineConverter.Convert(filteredPoints, proximityDistance); // smooth the path var smoothed = SmoothPath(path); var points = smoothed.Item1; var normals = AverageSmoothNormals(smoothed.Item2); // create the result return(new SubdivisionResult { SpinePoints = points, Normals = normals, }); }