Bézier Curve

This sketch draw a bézier curve to different degrees.
Move dots by dragging with mouse, change degree with buttons.



Short Explanation

Let's start with degree 1. Here we just do a linear interpolation between the two endpoints to get a new point.

p0∙t + p1∙(1-t)

Doing this for every t from 0 to 1 we get a line (our new curve). Change the value t with the slider above.

For degree 2 we do the same as for degree 1 (and also between the 2nd and 3rd point) to get the two purple dots. Then we linearly interpolate again between the two new purple dots to get the final red point. Doing this again for every t in [0,1] we get the curve.

For every other degree we do the same thing just once more than before. (The linear interpolation is not displayed from degree 4 onwards).

To calculate the curve one can also use the basis functions given by the Bernstein polynomials bi,n(x)
bi,n(x) = nCi xi(1-x)n-i
Where nCi is the binomial coefficient. These polynomials are displayed below. To get the curve we multiply each value of a point with its polynominal, i.e. p0∙b0,n + p1∙b1,n +...

sources on:
bézier curve wikipedia
Bernstein polynomials wikipedia