de Casteljau's algorithm for Bézier Curves

An algorithm to find a point on a Bézier curve for a given value of \(t\), called de Casteljau's algorithm is to recursively solve the equation

$$P^r_i(t)=(1-t)P^{r-1}_i(t)+t P^{r-1}_{i+1}$$

with

$$P^0_i(t)=P_i$$

For a Bézier curve of degree \(n\) with control points \(P_0,\ldots,P_n\) we evaluate \(P^n_0(t)\). This is equivalent to taking a point a fraction \(t\) along the line between subsequent control points, then forming lines joining these points (e.g. the points and lines in orange below), and recursively taking points a fraction \(t\) along the resulting lines (e.g. the points and lines in green below), until we arrive at a point.