Reference splineTangent()

splineTangent()

Calculates coordinates along a line that's tangent to a spline curve.

Tangent lines skim the surface of a curve. A tangent line's slope equals the curve's slope at the point where it intersects.

splineTangent() calculates coordinates along a tangent line using four points p0, p1, p2, p3. It expects points in the same order as the spline() function. splineTangent() works one axis at a time. Passing the points' x-coordinates returns the x-component of the tangent vector; passing the points' y-coordinates returns the y-component. The first parameter, a, is the coordinate of point p0.

The second and third parameters, b and c, are the coordinates of points p1 and p2.

The fourth parameter, d, is the coordinate of point p3.

The fifth parameter, t, is the amount to interpolate along the span from p1 to p2. t = 0 is p1, t = 1 is p2, and t = 0.5 is halfway between them.

Examples

Syntax

splineTangent(a, b, c, d, t)

Parameters

a
Number: coordinate of point p0.
b
Number: coordinate of point p1.
c
Number: coordinate of point p2.
d
Number: coordinate of point p3.
t
Number: amount to interpolate between 0 and 1.

Returns

Number: coordinate of a point on the tangent line.
Notice any errors or typos? Please let us know. Please feel free to edit src/shape/curves.js and open a pull request!

Related References