bezier
An array of three or four vectors, the start point, the endpoint, the first control point and optionally a second control point if the bezier is cubic.
The following functions are in the bezier module.
quadratic-point
quadratic-point()
Get the point on quadratic bezier at position t.
quadratic-derivative
quadratic-derivative()
Get the derivative (dx/dt) of a quadratic bezier at position t.
cubic-point
cubic-point()
Get the point on a cubic bezier curve at position t.
cubic-derivative
cubic-derivative()
Get the derivative (dx/dt) of a cubic bezier at position t.
to-abc
to-abc()
Get a bezier curve’s ABC coordinates. Returns them as a respective array</Type> of vector</Type>s.
/A\ <-- Control point of quadratic bezier
/ | <br /> / | <br /> /.-B-.\ <-- Point on curve
,' | ',
/ | <br /> s------C------e <-- Point on line between s and e
quadratic-through-3points
quadratic-through-3points()
Compute the control points for a quadratic bezier through 3 points.
quadratic-to-cubic
quadratic-to-cubic()
Convert a quadratic bezier to a cubic bezier.
cubic-through-3points
cubic-through-3points()
Compute the control points for a cubic bezier through 3 points.
split
split()
Split a cubic bezier into two cubic beziers at the point t. Returns an array</Type> of two bezier</Type>. The first holds the original curve start s, and the second holds the original curve end e.
cubic-arclen
cubic-arclen()
Get the approximate cubic curve length
cubic-shorten-linear
cubic-shorten-linear()
Shorten the curve by offsetting s and c1 or e and c2 by distance d. If d is positive the curve gets shortened by moving s and c1 closer to e, if d is negative, e and c2 get moved closer to s.
cubic-t-for-distance
cubic-t-for-distance()
Approximate bezier interval t for a given distance d. If d is positive, the functions starts from the curve’s start s, if d is negative, it starts form the curve’s end e.
cubic-shorten
cubic-shorten()
Shorten curve by distance d. This keeps the curvature of the curve by finding new values along the original curve. If d is positive the curve gets shortened by moving s closer to e, if d is negative, e is moved closer to s. The points s and e are moved along the curve, keeping the curve’s curvature the same (the control points get recalculated).
cubic-extrema
cubic-extrema()
Find cubic curve extrema by calculating the roots of the curve’s first derivative. Returns an array</Type> of vector</Type> ordered by distance along the curve from the start to its end.
cubic-aabb
cubic-aabb()
Returns axis aligned bounding box coordinates (bottom-left, top-right) for a cubic bezier curve.
catmull-to-cubic
catmull-to-cubic()
Returns an array of cubic bezier</Type> for a catmull curve through an array of points.
line-cubic-intersections
line-cubic-intersections()
Calculate the intersection points between a 2D cubic-bezier and a straight line. Returns an array of vector</Type>