4. Perform a least-squares curve fitting.
5. If the distance between the curve and the samples greatly exceeds the tolerance, split the samples in two parts, apply step
3 to both parts and connect the resulting segments.
6. If the distance between the curve and the samples exceeds the
tolerance, change the parameterization and restart at 4.
7. Otherwise, output the segment.