curve.closestPointTangent(point [, opt])

Return a line that is tangent to the curve at the point that lies closest to point.

The tangent line starts at the identified closest point. The direction from start to end is the same as the direction of the curve at the closest 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 function uses the same algorithm as the curve.closestPointT() function. The tangent at t closest to point is returned.

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.