views:

1754

answers:

2

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?

Update 1:

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

+2  A: 

Did you use a C# library earlier?

In C++, no standard library function for Bezier curves is available (yet). You can of course roll your own (CodeProject sample) or look for a math library.

This blogpost explains the idea nicely but in Actionscript. Translation should not be much of a problem.

dirkgently
A: 
  • If you just want to display a Bezier curve, you can use something like PolyBezier for Windows.

  • If you want to implement the routine yourself, you can find linear interpolation code all over the Intarnetz.

  • I believe the Boost libraries have support for this. Linear interpolation, not Beziers specifically. Don't quote me on this, however.

James D
Excellent! I think that code project example will do nicely :)
nbolton