polyline.tangentAt(ratio)
Return a line tangent to the polyline at point that lies ratio
(normalized length) away from the beginning of the polyline.
The function expects ratio
to lie between 0 and 1; values outside the range are constrained to 0 and 1, respectively.
The tangent line starts at the point at ratio
. The direction from start
to end
is the same as the direction of the polyline segment at the specified point. If the specified point is a point of discontinuity (e.g. it is a point shared by two polyline segments with different slopes), the tangent line is constructed for the earlier segment (i.e. the segment closer to the beginning of the polyline).
The algorithm ignores polyline segments that have zero length. If the polyline contains no valid segments (i.e. all polyline points are coincident), null
is returned. If the polyline has fewer than two points (exclusive), null
is returned, as well. The polyline.isDifferentiable()
function may be used in advance to determine whether the polyline contains at least one valid segment for wich a tangent may be found.