Draw a bezier curve(s) with a set of points from a vector

2.7k views Asked by At

I was wondering what would be the best and less complicated way of drawing a bezier curve in c++ with a set of points (roughly 100+ points) that are stored inside a vector From my understanding: -Bezier curves consist of 4 control points, the points in the middle dictate the direction/tangent of the curve

Would one possible method be to breakdown the points into different segments and from each segment determine the control points and tangents?

2

There are 2 answers

0
John Alexiou On

It is called a cubic spline and if you search you might find some C++ code for it. I used the free Fortran code from Numerical Recipes Online and ported it to C# with no problems.

0
ThomasMcLeod On

Would one possible method be to breakdown the points into different segments and from each segment determine the control points and tangents?

Yes, basically one connects the line segments end-to-end such that the slope approaching the end of the line segment is equal on both sides of the connection point. This is called a cubic spline. You can find algorithms for this here.