# Bézier Curves!

A lot of people are ready to talk about Bézier curves, as they’re a pretty fundamental part of solid geometry. Let’s be honest, if you’ve ever used so much as MS Paint and wanted a smooth curve, you’ve likely been introduced to these.

I’m working with them right now in Way of the Bee, as a matter of fact, in an effort to make by bird flights look a little more realistic and less obviously bound to 3D vectors. Grabbing a little bit of back knowledge—since it can be mildly dangerous to assume that you’re too much of an expert to learn—I noticed a lot of mysticism about them.

You have four points (at least for a cubic Bézier), and it forms a curve, efficiently, between the first point and the last, but what the heck are these other two points? Shifting them adjusts the curve, but how so? Can you make a circle with it?

## A Little History

Béziers were around before Pierre Bézier, but he did popularize them. They’re what’s called Bernstein polynomials, which have been well documented since the early twentieth century. What the heck is a Bernstein polynomial? They’re linear combinations—for Unity users, LERPs—of basis polynomials.

Technically, a solid year before Bézier documented their use in computer graphics, they were used by another mathematician, Paul de Casteljau. (de Casetjau’s algorithm is still frequently referred to when arbitrarily splitting a Bézier curve.) de Casteljau established IP protections in France, but not internationally, as Bézier unknowingly did a year later; there was never any evidence of hostility between the two.

Bézier himself was working for Renault as an automotive engineer, and needed to find a way to accurately describe the surface of a car without reducing it to a flat polyhedron. This is exceptionally important for automotive building, as flat planes can introduce terrible aerodynamic resistances.

He was no stranger to mathematics himself and was an absolutely brilliant solid geometry engineer, but he noticed that Bernstein polynomials offered a way to arbitrarily specify a curve at any point without reducing down to jagged polygons. He had a winner, he shared it, and it’s used in virtually all forms of industrial design, from blenders to airplanes, to this day.

## Fundamentals

If it’s been a while since you’ve been in a math class, a polynomial is an equation which consists of several terms added together.

Linear interpolation, commonly Lerping, is interpolating in a linear way between one vector and another.

By linear I technically mean “without any bumps, curve, or mathematical shenanigans” in the curve. And yes, if you look at it, you’ll note that between zero and one it covers a line between vector one and vector two; but it doesn’t have to.

I would like you to consider that vectors are also effectively polynomials. It’s just a question of expression. If we have the point <4, 5, 7>, we can just as easily express it as:

## Essence

So, what does it mean to create a Bernstein polynomial using these vectors as a basis? If we just had the first point and the last, it would again be a line; but if we have a curve then we’re departing from lines in a specific way—we aren’t just interpolating between two points, we’re also interpolating between two directions. The control points define the vectors, and magnitudes, of these directions.

This is why moving either control point will not change the initial or terminal points of the curve, but will totally change how they get there. We are interpolating between both P1 and P4, and the directions of P1P2 and P3P4.

The best way to understand any algorithm used in construction is to think about its constraints! So, to reiterate, we want it at a certain place, facing a certain direction, at the beginning; at the end, we want it at a different place, facing a different direction.

The first step in evaluating a Bézier curve is to find the line between P1 and P2, and the line between P3 and P4, as equations of t. This is a basic linear interpolation. We have two lines, now, which carry our initial and final directions.

We want to shift between the two, so we’ll be interpolating between them, too. How do you do that? Well, I’m going to introduce yet another line, but this one is a bit more flexible. As we increase t from zero to one, we’ll be describing points on P1P2 and on P4P3, let’s call them Q1 and Q2.

We’ll define L as a line between Q1 and Q2.

As we watch L evolve with the increase of t, we might notice something from this graph. It intersects the Bézier curve perfectly, begins at P1 facing along P1P2, and end at P4 facing along P4P3. We’ll call that interpolation, along the shifting line L, by value t, the point QL.

That’s exactly how it’s done. QL perfectly traces out the constraints of the Bézier curve.

In the instance of a non-cubic but quadratic Bézier curve, where there are only three points, you simply use P1P2 as your first vector, and P2P3 as your second.

Like all Bernstein polynomials, Bézier curves lend themselves to tesselation, or division into simpler subsets, very well. However, they don’t have to do so destructively; the information of the curve at each point is still well defined.

## So Why Can’t it be a Proper Circle?

I’m going to rough-and-tumble this one.

That can be proved quickly, with just a little math—though you should note that Béziers can get damned close to a circle. The equation of a circle is well known, but let’s start with that.

Here, x and y are coordinates, and r is the radius of the circle. In order to be identical to a circle, a Bézier curve would have to be reducible, for some parameters, to this. So, for the first time in this article, let’s consider the completely-unfolded double-linear-interpolation of the cubic Bézier curve.