Skip to main content

closest-points-between-beziers

function closestPointsBetweenBeziers(A: number[][], B: number[][], tolerance?: number | undefined, maxIterations: number): PointsWithDistance[]

Defined in simultaneous-properties/closest-distance-between-beziers/closest-points-between-beziers.ts:59

Calculates and returns an accurate approximation to the minimum distance between the two given bezier curves. (Actually returns the parameter values from which the distance can then easily be calculated.)

Note!
Green circles are draggable!
0

Parameters:

NameTypeDescription
Anumber[][]a bezier curve given by an ordered array of its control points e.g. [[0,0],[1,1],[2,1],[2,0]]
Bnumber[][]a bezier curve given by an ordered array of its control points e.g. [[0,0],[1,1],[2,1],[2,0]]
tolerancenumber | undefinedoptional; defaults to max(maxAbsCoordinate(A),maxAbsCoordinate(B))/1000_000; if the calculated absolute error bound is less than this, the result is returned; this is not a hard tolerance and the bound can be less accurate in hard cases (due to the maxIterations parameter). Luckily however, specifically the upper bound will be very accurate due to its fast convergence in such hard cases (see the paper)
maxIterationsnumberoptional; defaults to 50; if the desired guaranteed error bound has not been achieved after maxIterations then the result will be returned