Bezier Splines

This applet shows cubic and quadratic Bezier spline curves.

Let P0, P1, Q0, Q1, etc. be points. The following are methods
for generating these curves.

Generation of a straight line segment:
P(t) = (1-t)P0 + tP1

Generation of quadratic Bezier Spline:
Q(t) = (1-t)2Q0 + 2 t(1-t)Q1 + t2Q2

Generation of cubic Bezier Spline:
P(t) = (1-t)3P0 + 3 t(1-t)2P1 + 3 t2(1-t)P2 + t3P3

The parameter t changes from 0 to 1 as we go from one end
of the curve to another.

The cubic curve is in the centre of the drawing area. The
quadratic curve, which is a parabola, is shown at the upper
right corner. You can drag the points which define these curves.

The cubic Bezier curve is much used in computer graphics.
The curveto command of PostScript adds a cubic Bezier spline
to the current path.

Source Code