I'd like to implement a Bézier curve. I've done this in C# before, but I'm totally unfamiliar with the C++ libraries. How should I go about creating a quadratic curve?

```
void printQuadCurve(float delta, Vector2f p0, Vector2f p1, Vector2f p2);
```

Clearly we'd need to use linear interpolation, but does this exist in the standard math library? If not, where can I find it?

Sorry, I forgot to mention I'm using Linux.

Recently I ran across the same question and wanted to implemented it on my own. This image from Wikipedia helped me:

The following code is written in C++ and shows how to compute a quadratic bezier.

```
int getPt( int n1 , int n2 , float perc )
{
int diff = n2 - n1;
return n1 + ( diff * perc );
}
for( float i = 0 ; i < 1 ; i += 0.01 )
{
// The Green Line
xa = getPt( x1 , x2 , i );
ya = getPt( y1 , y2 , i );
xb = getPt( x2 , x3 , i );
yb = getPt( y2 , y3 , i );
// The Black Dot
x = getPt( xa , xb , i );
y = getPt( ya , yb , i );
drawPixel( x , y , COLOR_RED );
}
```

With (x1|y1), (x2|y2) and (x3|y3) being P0, P1 and P2 in the image. Just for showing the basic idea...

For the ones who ask for the cubic bezier, it just works analogue (also from Wikipedia):

This answer provides Code for it.

Licensed under: CC-BY-SA with attribution

Not affiliated with: Stack Overflow