I believe that every mathematical formula is the result of man’s effort to understand and model concepts. This particular trip is dedicated to understanding curves.
An excellent starter question would be;
Why would anyone want to understand curves?
After all, curves exist in nature
It is common knowledge that curved objects exists all around us: bird eggs, the sun, the moon, oranges, bananas and countless other things.
Curves also exist in us; the shape of our heads and eyes are visible examples of these.
Humans got fascinated with these shapes and started drawing and creating new curved objects like bowls and wheels.
Many of these new objects were relatively easy to create with our hands and the occasional help of low-level tools such as carving knifes and drawing tools.
However, it was almost impossible to draw the same two curved shapes with precision.
Fortunately, this did not pose a problem at that stage. But as technology progressed to the era of invention, things became more difficult.
Engineers started developing advanced machines like airplanes and vehicles. Since the success of their developments greatly depended on precision and accuracy, the was no room for the use of unreliable methods of drawing and carving curves.
Whenever they created a successful model, they needed to replicate the exact same curve in another model. So, they started looking for ways to draw multiple curves of the same dimension.
Mechanically controlled splines
A paper I read by Benjamin T. Bertka on Bezier curves and B-splines mentioned how these automobile engineers approached this problem. To create the curves and splines required for the construction of chassis (vehicle frames) they made use of flexible wood or plastic strapped unto protrusions (called ducks) connected to heavy lead weights. By manipulating the positioning of these ducks these engineers were able to pull the flexible piece into splines and curved shapes.
The principle is similar to how we could use our fingers to bend a plastic ruler into a curve.
Once they got the right shape, they would lock the curve in place using the ducks and use it as a reference for their production process.
This worked great until they realized that if they kept creating new setups for every different curve, they would exhaust an awful amount of space. Thus, the hunt for another solution began.
Engineering design, mathematical modeling and computer aided design
The world was progressing quickly.
Engineering design became a popular practice as engineers and architects found it effective to sketch out the specifications of their intended products before proceeding to the implementation stage.
It started from paper sketches and blueprints to product simulations run be computer programs.
Knowledge of mathematical concepts like linear algebra and geometry were the bedrock upon which the algorithms for computer aided design where built.
Using the formula for the shapes like circles and squares, CAD programs where able to plot out the points and trace the lines required to display a given object.
However, there was no known mathematical formular for odd curves - by odd curves, I am refering to all sorts of curves apart from the regular circular shapes. So most efforts were made towards developing a mathematical description for curves.
Several people came up with awesome ideas about curves and splines. We are going to take a look at their contributions and perspectives as we proceed.
Chiakin's algorithm
Let us say that we want to draw a curve, and we have an image of what the curve should look like in our mind.
We could start out with an open polygon.
To draw this open polygon we connect a couple of lines to each other at different angles to get a shape that vaguely resembles the curve we have in mind.
Then we go ahead to find the midpoint of each line that makes up this polygon by dividing the length of each line into 2 equal parts.
By dividing the distance between the midpoint and the edges of each line, we can further divide the lines of the polygon into 4 equal parts.
If the length of a line is 1 unit, one out of the four parts is equal to 0.25 units.
And we can label the points on each line as;
[0(edge), 0.25(quater point), 0.5(midpoint), 0.75(quater point), 1.0(edge)]
Of course, we can also calculate the quarter points without using the midpoint.
The next step involves selecting the line between points 0.25 and 0.75.
We can remove the midpoint markers and draw new lines between the quarter points on each line.
The edges of the yellow lines are then connected to each other with straight lines to complete a new polygon.
This new polygon will have more sides than the first one.
The above process is usually regarded as the first iteration or cycle.
The second iteration of this process will produce another polygon as can be seen below.
By repeating this cycle several times we can expect to get a close approximation of a smooth curve.
George Chiakin developed this idea as an algorithm for generating curves in 1974. One way to look at this algorithm is to imagine repeatedly chopping off the corners of a polygon down to a smooth curve. Chiakin's algorithm is one of the first recursive subdivision algorithms for curve generation.
Several researchers like Ed Catmull and Jim Clark have extended the concepts from this algorithm to develop mesh subdivision algorithms capable of generating curved surfaces.
While Chiakin's algorithm is a very simple way of generating curves, it's popularity decreased as more efficient algorithms that require less iterations were developed.
It is interesting to note that the idea behind Chiakin's algorithm can be reversed from curve back to polygon.
In this scenario, we will start out with a curve such as the one below, and proceed to pick out several points along the curve's length.
Then we draw tangents to the curve at each of the selected points.
The points where these tangents meet form the vertices of the control polygon.
The resultant polygon can be used to get the intial curve using Chiakin's method.
However, depending on the distance of the selected points on the curve, the result of Chiakin's algorithm on this generated polygon might not give the exact same initial curve. If the points are not spaced closely enough, some critical information about the curve might be lost.
I would like to explore using Chiakin's algorithm and it's reverse process to try to draw complicated looking curves with Octave or another plotting software. But that would be a journey for another week.
There's another interesting approach to generating curves. It was developed through the contribution of three men; Paul de Casteljau, Sergei Natanovich Bernstein, and Pierre Bezier.
Bernstein Polynomials
Sergei Bernstein formulated Bernstein's basis polynomials and used it to provide proof for a theorem called Wiestrass Approximation Theorem. This theorem states that a closed interval of a continuous function can be uniformly approximated by a polynomial function. I honstly did not understand much about this until I saw a summary that mentioned the Bernstein basis' connection to probability theory. Especially in modeling events that follow a binomial distibution. However, I will leave this topic for a write up on statistics.
The important thing to note for this topic is the formular for the bernstein basis which looks like this;
Then Paul de Casteljau and Pierre Biezer developed similar methods for generating curves using the principle of interpolation, although de Casteljau formulated his algorithm much earlier.
Ruler games
After watching a couple of videos and reading materials about Bezier curves, I remembered playing around with a ruler and pen.
I would typically draw two lines connected at one end at a certain angle.
Then go ahead to a rule line from a point on one line to a point on the second line.
Maintaining a relatively equal spacing, I would continue ruling lines across the two main lines until I reached the end. I was intrigued with the resultant curve that was created by the intersecting lines. This was actually an application of de Casteljau's algorithm.
De Casteljau's algorithm/ Bezier's polynomials
De Casteljau's algorithm with Bezier's polynomials is very similar to the process described above.
Linear
To build solid understanding, let us start with two points; P1 and P2.
We can connect P1 and P2 with a straight line.
The position of any point on the line between P1 and P2 can be gotten from the equation above.
q0(t) = the point on the line
P0 & P1 = control points on the line
t = a number that varies from 0 to 1
On close inspection we can see that this equation looks awfully familiar with the formula used to calculate the points for a new polygon on Chiakin's algorithm.
However, while in this case, t can take on any value from 0, 0.001, up to 1, the formular for Chiakin's algorithm uses values of 0.25 and 0.75 only.
This equation works such that we can not get the positions of any points outside the designated lines, and P0 and P1 act as the limits.
For t = 0; q0 = (1-0)P0 + (0)P1
q0 = P0 + 0
q0 = P0 (position at the edge where P0 is located)
For t = 1; q0 = (1-1)P0 + P1
q0 = (0)P0 + P1
q0 = P1 (position at the edge where P1 is located)
For values of t between 0 and 1, the points will have positions along the line.
It is important to note that we cannot generate a curve using only two control points.
Quadratic
What if we add another control point?
We now have three points P0, P1, and P2.
In this case, we can draw two lines; line P0|P1 and line P1|P2
We already got the equation for finding the position of any point along P0|P1;
q0 = (1-t)P0 + tP1
The equation for finding the position of any point along P1|P2 can also be found using;
q1 = (1-t)P1 + tP2
Let us draw a straight line conneting points q0 and q1, then we can formulate the equation to find any point along line q0|q1 as;
r0 = (1-t)q0 + tq1
Remember that q0 and q1 have their own expressions. If we substitute them in the equation for r0, we have;
Looking back at Bernstein's polynomials you would notice its similarity with the final form of the quadratic bezier polynomial. You would also notice that the coefficients follow Pascal's triangle.
Repeating the interpolation process for third order bezier curve will give a final equation with a similar form at that of the quadratic bezier. Since these expressions follow the pattern of Bernstein's polynomials, mathematical expressions for higher order curves can be formed easily.
Remember that a quadratic curve needs 3 control points, third curves need 4 points and so on.
Vizualization of bezier curves using Octave
Eager to try out the algorithm and see how bezier curves look, I plotted the curves for quadratic, 3rd order and fouth order curves on Octave.
Quadratic
Third order curve
Fourth order curve
Whew!
This was quite a lot.
But with this I have been able to summarize all I have learned about Bezier curves. The next article will cover B-splines.
I will list out the resources I found useful while learning and creating this post below.
Apart from wikipedia and a couple of online sources, these papers were helpful;
Bertka, Benjamin. (2008). An Introduction to Bezier Curves, B-Splines, and Tensor Product Surfaces with History and Applications.
Rida T. Farouki. The Bernstein polynomial basis: a centennial retrospective a “sociological study” in the evolution of mathematical ideas
Of course, the videos helped me as well, some interesting ones are listed below.
The Beauty of Bezier Curves by Freya Holmer
Bezier Curves explained by Guidev
UC Davis Lecture NURBS crash course by minRef