de Casteljau’s construction · Bernstein weights

Bézier curve

A Bézier curve is what is left when you take the same fraction t along every side of a polygon, then along every side of the new, shorter polygon, until one point remains; as t runs from 0 to 1 that point draws the curve.

Bézier curves in this visualization

A Bézier curve of degree n is set by n + 1 control points P0,…,PnP_0, \dots, P_n: two points give a segment, three a quadratic, four the cubic of drawing programs. Its point B(t)B(t), red on the picture, comes from repeatedly taking the fraction t along every side of the control polygon. Here you can move the points, sweep t from 0 to 1 and watch the lines of the construction leave threads that outline the curve.

Construction shows the polygons of every level at the current t, each with one side fewer than the last. Sweep runs t from 0 to 1, leaving threads of the construction at equal steps of t, coloured by t. The curve itself is the thin line.

Written out, the construction is a ladder of weighted averages, de Casteljau’s algorithm:

Pi0=Pi,Pik(t)=(1−t) Pik−1(t)+t Pi+1k−1(t),B(t)=P0n(t).P_i^0 = P_i, \qquad P_i^k(t) = (1 - t)\,P_i^{k-1}(t) + t\,P_{i+1}^{k-1}(t), \qquad B(t) = P_0^n(t) .

When the ladder is multiplied out, each control point gets a sum of products of n factors, each factor 1 − t or t. For PiP_i every product has exactly i factors of t, and there are (ni)\binom{n}{i} such products, so

B(t)=∑i=0nbi,n(t) Pi,bi,n(t)=(ni)ti(1−t)n−i.B(t) = \sum_{i=0}^{n} b_{i,n}(t)\, P_i, \qquad b_{i,n}(t) = \binom{n}{i} t^{i} (1 - t)^{n-i} .

These weights are the Bernstein polynomials, and the inset draws them. For 0≤t≤10 \le t \le 1 they are never negative and add up to 1, so B(t)B(t) is a weighted average of the points and the curve never leaves their convex hull. Moving one point PiP_i by a vector Δ moves every point of the curve by bi,n(t) Δb_{i,n}(t)\,\Delta, most near t=i/nt = i/n. That part of the curve is not always the part nearest the point.

At t = 0 every level starts at P0P_0, so B(0)=P0B(0) = P_0, and likewise B(1)=PnB(1) = P_n. The curve passes through its two ends and usually misses the other points. The last level of the construction is a single segment, and unless it shrinks to a point, it lies along the curve’s tangent:

B′(t)=n(P1n−1(t)−P0n−1(t)),B′(0)=n (P1−P0),B′(1)=n (Pn−Pn−1).B'(t) = n \bigl(P_1^{n-1}(t) - P_0^{n-1}(t)\bigr), \qquad B'(0) = n\,(P_1 - P_0), \qquad B'(1) = n\,(P_n - P_{n-1}) .

So the curve leaves P0P_0 heading for P1P_1 and arrives at PnP_n coming from Pn−1P_{n-1}, unless the two points at that end coincide. That is why a drawing program shows a cubic’s middle points as handles sticking out of its ends.

Each thread of the last level that is not a single point touches the curve at the point it carries. A thread one level lower touches the curve of fewer neighbouring points in the same way, so every family of threads outlines a curve of its own, and the lower-degree curves show inside the polygon. Outlining is not wrapping from one side: where the curve has an inflection, it crosses its own tangent, and the threads lie on both sides. When its three control points are not on one line, a quadratic’s threads are the string art of thread wound between two straight rows of nails, and the curve they outline is a parabola.

The construction at t = s also cuts the curve in two. The first points of its levels are the control points of the piece from 0 to s, and the last points those of the piece from s to 1, which Split shows. Cut in halves again and again, the pieces’ polygons close in on the curve. Raise degree goes the other way: one more control point, the same curve, and a polygon closer to it. A point added by pressing the picture changes the curve instead.

Paul de Casteljau at Citroën worked out the construction in 1959, and Pierre Bézier at Renault reached the same curves independently and published them in the 1960s.

Things to notice

  • Equal steps of t need not cover equal distances along the curve.
  • The strongest shading is not the curve. It is where threads overlap most, which can lie a little off the curve.

Related