Bezier Curve in Computer Graphics
A Bezier curve in computer graphics is a mathematical representation of a smooth curve defined by a set of control points. It’s widely used to create and manipulate curves and surfaces in various design and visualization applications. The curve’s shape is influenced by the positions of its control points, allowing for precise control over its curvature and trajectory. Bezier curves are fundamental in computer graphics software for creating smooth paths, shapes, and animations. Another method to draw a smooth curve shape is B-spline curve, which works like a flexible string.
C program of Bezier Curve in Computer Graphics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | //C program of Bezier curve in computer graphics #include<stdio.h> #include<graphics.h> #include<math.h> #include<conio.h> int x[4]={200,120,170,350}; int y[4]={200,110,55,100}; void beziercurve() { int i; double t,xt1,yt1; for (t = 0.0; t < 1.0; t += 0.0005) { xt1 = pow(1-t,3)*x[0]+3*t*pow(1-t,2)*x[1]+3*pow(t,2)*(1-t)*x[2]+pow(t,3)*x[3]; yt1 = pow(1-t,3)*y[0]+3*t*pow(1-t,2)*y[1]+3*pow(t,2)*(1-t)*y[2]+pow(t,3)*y[3]; putpixel (xt1,yt1,WHITE); } } void main() { int gd = DETECT, gm; initgraph (&gd, &gm, "c:\\turboc3\\bgi"); beziercurve(); getch(); closegraph(); } |
Output