quadratic-to-polyline
function quadraticToPolyline(ps: number[][], tolerance?: undefined | number): number[][]
Defined in fit/quadratic-to-polyline.ts:31
Transforms the given quadratic bezier curve into a polyline approximation to within a given tolerance and returns the result.
Note!
Green circles are draggable!
Example
quadraticToPolyline([[1, 1], [15, 10.3125], [15.375, 0.875]], 0.023)//=> [[1, 1], [2.69677734375, 2.0908203125], [4.287109375, 3.03515625], [5.77099609375, 3.8330078125], [7.1484375, 4.484375], [8.41943359375, 4.9892578125], [9.583984375, 5.34765625], [10.64208984375, 5.5595703125], [11.59375, 5.625], [12.43896484375, 5.5439453125], [13.177734375, 5.31640625], [13.81005859375, 4.9423828125], [14.3359375, 4.421875], [14.75537109375, 3.7548828125], [15.068359375, 2.94140625], [15.27490234375, 1.9814453125], [15.375, 0.875]]
Parameters:
Name | Type | Description |
---|---|---|
ps | number[][] | a quadratic bezier curve given as an ordered array of its control point coordinates, e.g. [[0,0], [1,1], [2,1], [2,0]] |
tolerance? | undefined | number | defaults to 2**-10 of the maximum coordinate of the given bezier curve; a tolerance given as the maximum Hausdorff distance allowed between the polyline and the bezier curve |