2D Airfoil Geometry Manipulation via Composite Quadratic Bézier Curves and Python

September 14, 2016

Before any type of shape optimization can occur, the geometry needs to be parameterized (usually…). One of the easiest ways to accomplish this is through the use of Bézier curves. For this tutorial, we’re not going to manipulate an existing geometry, rather we’re going to generate the geometry from scratch using a series of connected Bézier curves called a composite Bézier curve.

A quadratic Bézier curve is defined using three control points. The first and third point are what’s called anchor points, while the middle point controls the shape of the curve. For \( 0 \le t \le 1 \), a quadratic Bézier curve is defined as:

$$ B \left ( t \right ) = \left ( 1 - t \right ) \left [ \left ( 1 - t \right ) P_0 + t P_1 \right ] + t \left [ \left ( 1 - t \right ) P_1 + t P_2 \right ] $$

As a quick mental example, t, is a one dimensional array of values going from 0 to 1 such as t=[0.0,0.25,0.5,0.75,1.0]. As we loop through our values within t, we can see that the weighting of each control points changes. At t[0]=0.0, \( P_0 \) has 100% of the influence. As we cycle forward to t[3]=0.5, \( P_1 \) has the dominate influence. And finally, at t[5]=1.0, \( P_2 \) has 100% of the weighting. Below, I have plotted the quadratic Bézier curve basis function which graphically shows the influence each control point has on the curve as you progress from t=0 to t=1.

To implement this in Python we’ll have two sets of the above equation. One for the x-coordinates and one for the y-coordinates. Below is a very simple code that demonstrates what a single quadratic Bézier curve looks like. GitHub script download (here)

Below is an image of the final product. If we look back at the quadratic Bézier curve formula, \( P_0 \) is the red control point located at (0,0), \( P_1 \) and \( P_2 \) are located at (0.5,1) and (1,0) respectively.

If we animate the above script to show the progression, it becomes very easy to see how Bézier curves actually work.

At least for me, the animation really helps bring a better understanding to the underlying math. So how does this relate to airfoils, geometry manipulation, or aerodynamic design? Simple, all we need to do now is string together a series of these curves so that we can create something useful. This is what’s called a composite Bézier curve, essentially a piecewise series of individual Bézier curves lined up to form a single curve. This will allow us to start creating and manipulating complex geometry. Below is a simple script for generating a composite Bézier curve based off an arbitrary number of control points. GitHub download (here).

The above example is a generic airfoil featuring 11 unique control points and a finite thickness trailing edge. Now that we have covered the basics, in a future post, I’ll explain how we can use this script to optimize airfoils for a given performance characteristic.