curve.closestPointT(point [, opt])

Return the t value of the point on the curve that lies closest to point.

The curve is first subdivided, according to opt.precision (refer to curve.length() documentation for more information about precision and curve flattening). Then, one subdivision is identified whose endpoints are the closest to point. A binary search is then performed on that subdivision, until a curve is found whose diffrence between endpoints' distance to point lies within opt.precision. The t value of the closest endpoint is returned by the function.

The default value for opt.precision is 3; this corresponds to maximum observed error of 0.1%.

The opt.subdivisions property may be specified, directly providing an array of pre-computed curve subdivisions with which to begin the algorithm. Use the curve.getSubdivisions() function to obtain an array of curve subdivisions. The opt.precision property is still necessary, however; it determines the precision of the point search algorithm.