closest-point-on-bezier-certified
function closestPointOnBezierCertified(ps: number[][], p: number[]): object[]
Defined in simultaneous-properties/closest-and-furthest-point-on-bezier/closest-point-on-bezier-certified.ts:52
Returns the closest point(s) (and parameter t
value(s)) on the given
bezier curve to the given point (with t ∈ [0,1]
).
- guaranteed accurate to within
4*Number.EPSILON
in the returnedt
value(s) - in some cases there can be more than one closest point, e.g. on the axis of symmetry of a parabola
- the returned point(s) are objects with the following properties:
p
: the best estimate point on the bezier curve (calculated from the root intervalri
)t
: the best estimatet
parameter value (calculated from the root intervalri
)d
: the best estimate closest distance from the point to the bezier curve (calculated from the root intervalri
)ri
: a root interval guaranteed to contain the actualt
valuebox
: a small box guaranteed to contain the relevant point on the bezier curvedSquaredI
: a small squared distance interval guaranteed to contain the actual distance squared between the point and the bezier curve
Parameters:
Name | Type | Description |
---|---|---|
ps | number[][] | an order 0,1,2 or 3 bezier curve given as an ordered array of its control point coordinates, e.g. [[0,0], [1,1], [2,1], [2,0]] |
p | number[] | a point, e.g. [1,2] |