curve.tAtLength(length [, opt])
Return the t
value of the point that lies length
away from the beginning of the curve.
If negative length
is provided, the algorithm starts looking from the end of the curve. If length
requested is higher than curve length, the t
of the closest curve endpoint (0 or 1) is returned instead.
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 which contains the point at length
. A binary search is then performed on that subdivision, until a curve is found whose endpoint lies within opt.precision
away from length
. The t
value of that 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 from which to calculate curve length. 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.