bezier

Provides basic functions for sampling points and tangent vectors on a quadratic or cubic Bézier curve.

A quadratic Bézier curve is represented by endpoints p0 and p2, and a control point p1. A cubic Bézier curve is represented by endpoints p0 and p3, and control points p1 and p2. t is the curve's parameter – a value between 0 and 1.

The functions are available for 1 through 4 spatial dimensions. The tangent vectors are not normalized.

Get point along a quadratic Bézier curve

float bezierPoint(float p0, float p1, float p2, float t);
vec2 bezierPoint(vec2 p0, vec2 p1, vec2 p2, float t);
vec3 bezierPoint(vec3 p0, vec3 p1, vec3 p2, float t);
vec4 bezierPoint(vec4 p0, vec4 p1, vec4 p2, float t);

Get point along a cubic Bézier curve

float bezierPoint(float p0, float p1, float p2, float p3, float t);
vec2 bezierPoint(vec2 p0, vec2 p1, vec2 p2, vec2 p3, float t);
vec3 bezierPoint(vec3 p0, vec3 p1, vec3 p2, vec3 p3, float t);
vec4 bezierPoint(vec4 p0, vec4 p1, vec4 p2, vec4 p3, float t);

Get the derivative (tangent vector) of a quadratic Bézier curve

float bezierTangent(float p0, float p1, float p2, float t);
vec2 bezierTangent(vec2 p0, vec2 p1, vec2 p2, float t);
vec3 bezierTangent(vec3 p0, vec3 p1, vec3 p2, float t);
vec4 bezierTangent(vec4 p0, vec4 p1, vec4 p2, float t);

Get the derivative (tangent vector) of a cubic Bézier curve

float bezierTangent(float p0, float p1, float p2, float p3, float t);
vec2 bezierTangent(vec2 p0, vec2 p1, vec2 p2, vec2 p3, float t);
vec3 bezierTangent(vec3 p0, vec3 p1, vec3 p2, vec3 p3, float t);
vec4 bezierTangent(vec4 p0, vec4 p1, vec4 p2, vec4 p3, float t);