Bezier Curves


Date: January 20, 2023


Bezier Curves are a wonder of math coming together with technology; the first practical use was in the automotive industry, where Pierre Bezier widely published them.

An early use of Bezier curves to draw a car body
Illustration from Pierre BĂ©zier's conference of October 23, 1964.

Although they had been discovered and rediscovered before that. This isn't a history lesson, though, so let's dive into how bezier curves work and how to construct them.

To understand bezier curves, we first have to understand two concepts: linear interpolation and parametric equations. Linear interpolation is basically just moving between two points. The special thing about linear interpolation, though, is that instead of controlling where the point is with true distance, we control it with fractions. For example, a linear interpolation with 0.5 (1/2) for its distance would not be 0.5 units away from the first point but halfway between the two points. Try moving the points and the slider "c" to see how linear interpolation works.

The second topic, parametric equations, is more complex but still manageable. Think of a parametric equation as a slider from 0 to 1 (see the correlation) affecting a point. For our variable, we use "t". The thing that separates a parametric equation from a variable affecting a point is that a parametric equation displays all points at once as a line. In the example below, there is the parametric equation (t, t), a slider, c, and the equation (c, c). You can see that when the slider is set from 0 to 1, it traces the parametric equation. The only difference between the two equations is that a linear interpolation is one value of "t" while a parametric is all of them at the same time.

Now, onto bezier curves. Bezier curves are a mix of the two concepts. They are linear interpolations of parametric equations. Whatttttttt! How can you take a linear interpolation of a line!? That's not possible! It may seem impossible at first, but when you realize that a parametric equation is just a moving point, it all makes a lot more sense.

As the linear interpolation is being drawn, the point is also acting as the starting point for another linear interpolation. This causes the parametric equation to curve. The problem with this equation is that it only truly controls one side of the curve, so the next logical step is to linearly interpolate two linear interpolations (yes, it does get more complex).

We can see in the example that we linearly interpolate between the 1st and 2nd points, and then from the 2nd point to the 3rd. We then interpolate between the two linear interpolations to get control over both sides. Just like that, we have created a bezier curve. When I told you it was just a combination of parametric equations and linear interpolations, I wasn't lying. What we have here is a quadratic Bezier curve. It is called a quadratic bezier curve because if you break the equation into its x and y parts, they form a quadratic equation. The next logical step would be to create a cubic Bezier curve. All this means in practicality is four control points, where there is one start point, one endpoint, and two control points that each have primary control over their side of the curve, and limited control over the other side.

In practice this looks a little something like this; First, we linearly interpolate between the 1st and 2nd points, I1. Then we interpolate between the 2nd and 3rd points, I2. Then between the 3rd and 4th, I3. We then interpolate I1 and I2 together to form I4. We do the same to I2 and I3 to form I5. Lastly, we interpolate I4 and I5 together to get the finished cubic bezier curve. This is somewhat complicated so take your time to understand it, this will be the basis for all of our future examples. The graph below shows a construction animation for the linear interpolation method of a bezier curve.

As the previous statement implies, there is more than one method for making bezier curves, each more interesting than the last. The technical name for the form we just looked at is called De Casteljau’s algorithm. But before we move on to different types of Bezier curves, it is important to understand how we get to these different forms. The full equation for a bezier curve using the linear interpolation method is:

(1-t)((1-t)((1-t)P1+tP2)+t((1-t)P2+tP3)) +t((1-t)((1-t)P2+tP3)+t((1-t)P3+tP4))

So we can see that all it is is a lot of polynomial multiplication. We can solve this to get:

P1-3tP1+3tP2+3t2P1-6t2P2+3t2P3-t3P1+3t3P2-3t3P3+t3P4

This form is very useful because it can give us the matrix form of a bezier curve:

1, t, t2, t3
1, -3, 3, -1
0, 3, -6, 3
0, 0, 3, -3
0, 0, 0, 1
P1
P2
P3
P4

All of these are cool, but to me, the most interesting form of a bezier curve is the Bernstein polynomial version. These were not invented for bezier curves but became very important when computer graphics were invented. A form that used parametrics was used for bezier curves. We can derive this algorithm from our expanded linear interpolation method by grouping the terms that contain the same points and simplifying them together to get:

(1-t)3P1+3(1-t)2tP2+3(1-t)t2P3+t3P4

you may notice that the equation is just each point being multiplied by some coefficient. If we extract these coefficients we get the this:

(1-t)3

3(1-t)2t

3(1-t)t2

t3

These are called the Bernstein polynomials and have an interesting property that the sum at any given point is 1.

This form of a bezier curve is probably the most common one on the internet because it is so optimized and simple. The way that Bernstein polynomials work is fascinating and is more akin to vector addition than linear interpolations. Each equation dictates the fraction of a linear interpolation from an arbitrary point (in this case, (0,0). We can ignore the "+t(P1)" part of the equation because we are multiplying by 0). It then just adds up all of the vectors it has created, and it forms the bezier curve! It is such an elegant solution to a complex problem, which is why it is so popular. Below is an interpretation of the Bernstein polynomial construction of a bezier curve.

That's about all I know about Bezier curves! Go out and learn these topics for yourself and get interested! Thanks for reading!