Bezier Curves and Bezier Surfaces generation with C/C++ in Code::Blocks

Brief Theory of Bezier Curve
In order to draw curvy surface we implement Bezier curve algorithm. In drawing Bezier we first define n+1 control point pk = (xk, yk, zk) with k varying from 0 to n. And the coordinate points are blended to produce following position vectors that define the path of an approximation Bezier polynomial function between p0 and pn.

Beizer Polynomial Function
The Bezier blending functions BEZk,n(u) are the Bernstein polynomials: BEZk,n(u)=C(n,k)uk(1-u)n-k
Where the C(n, k) are binomial coefficients.
Equivalently, we can define Bezier blending functions with the recursion calculation.
BEZk,n (u) = (1-u) BEZk,n-1(u)+u BEZk-1,n-1(u), n>k≥1
With BEZk,k = uk , and BEZ0,k = (1-u)k.


C Source Code

Note: to run this code in your machine with Code::blocks IDE, add a link
library libgdi32.a (it is usually inside MinGWlib )  in linker setting. 
Output

Beizer Surface

SHARE Bezier Curves and Bezier Surfaces generation with C/C++ in Code::Blocks

You may also like...

4 Responses

  1. wow that is very impressive!!

    Bibek123, I need your help once again, we were discussing about Fractals in our graphing class, and the teacher assigned us to compile any kind of fractal geometry (like the Mandelbrot Set) using C, so I was wondering, do you have any fractal code running in C? I will really appreciate if you can help me with this, I already search on google for fractals using c but most of the code I downloaded doesn't run on codeblocks, so I was hoping if you have something that I can use to present it to our teacher.

    Once Again, thank you very much for your great programming tutorials and help you provide us.

  2. Anonymous says:

    Thanks a lot for this, helped in more ways than one.

    Mike

  3. Anonymous says:

    Can you please tell me what the param (int Points) of the BezierCurve function specify's exactly?

  4. Anonymous says:

    Here is a specific question,

    If we have a bezier curve (cuadratic), and from the center of the curve we have a circle, how to identify by programming the intersection points ? having and specific radio

Leave a Reply

Your email address will not be published. Required fields are marked *

Share