curve.tangentAtLength(length [, opt])
Return a line that is tangent to the curve at a point that lies
length away from the beginning of the curve.
length is provided, the algorithm starts looking from the end of the curve. If
length is higher than curve length, a line tangent to the closest curve endpoint is returned instead.
The tangent line starts at the specified point. The direction from
end is the same as the direction of the curve at the specified point.
If the control points of the curve all lie at the same coordinates,
null is returned (it is impossible to determine the slope of a point). The
curve.isDifferentiable() function may be used in advance to determine whether tangents can exist for a given curve.
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. That endpoint is used as the start of the tangent line.
The default value for
opt.precision is 3; this corresponds to maximum observed error of 0.1%.
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.