cubicbezier-0.1.0: Efficient manipulating of 2D cubic bezier curves.

Safe HaskellNone

Geom2D.CubicBezier.Approximate

Synopsis

Documentation

approximateCurve :: CubicBezier -> [Point] -> Double -> (CubicBezier, Double, Double)Source

approximateCurve b pts eps finds the least squares fit of a bezier curve to the points pts. The resulting bezier has the same first and last control point as the curve b, and have tangents colinear with b. return the curve, the parameter with maximum error, and maximum error. Calculate to withing eps tolerance.

approximateCurveWithParams :: CubicBezier -> [Point] -> [Double] -> Double -> (CubicBezier, Double, Double)Source

Like approximateCurve, but also takes an initial guess of the parameters closest to the points. This might be faster if a good guess can be made.