C Program to implement Bezier curves for a given set of control points.

```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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 #include <stdio.h> #include <stdlib.h> #include <graphics.h> #include <math.h>   void bezier (int x, int y) { int gd = DETECT, gm; int i; double t;   initgraph (&gd, &gm, "..\\bgi");   for (t = 0.0; t < 1.0; t += 0.0005) { double xt = pow (1-t, 3) * x + 3 * t * pow (1-t, 2) * x + 3 * pow (t, 2) * (1-t) * x + pow (t, 3) * x;   double yt = pow (1-t, 3) * y + 3 * t * pow (1-t, 2) * y + 3 * pow (t, 2) * (1-t) * y + pow (t, 3) * y;   putpixel (xt, yt, WHITE); }   for (i=0; i<4; i++) putpixel (x[i], y[i], YELLOW);   getch(); closegraph(); return; }   void main() { int x, y; int i;   printf ("Enter the x- and y-coordinates of the four control points.\n"); for (i=0; i<4; i++) scanf ("%d%d", &x[i], &y[i]);   bezier (x, y); }```

5 Responses to “C Program to implement Bezier curves for a given set of control points.”

1. Taruchit

Cubic Bezier curve

#include
#include
int X()
{
int x;
printf(“\nEnter the value of x: “);
scanf(“%d”,&x);
return x;
}
int Y()
{
int y;
printf(“\nEnter the value of y: “);
scanf(“%d”,&y);
return y;
}
float Square(float u)
{
return (u*u);
}
float Cube(float u)
{
return (u*u*u);
}
int main()
{
int x1,x2,x3,x4,y1,y2,y3,y4;
float u=0.0,x,y,v1,v2,v3,v4;
int gd=DETECT,gm;
x1=X();
y1=Y();
x2=X();
y2=Y();
x3=X();
y3=Y();
x4=X();
y4=Y();
initgraph(&gd,&gm,NULL);
for(u=0.0;u<1.0;++u)
{
v1=Cube(1-u);
v2=3*Square(1-u);
v3=(1-u)*Square(1-u);
v4=Cube(u);
x=(x1*v1)+(x2*v2)+(x3*v3)+(x4*v4);
y=(y1*v1)+(y2*v2)+(y3*v3)+(y4*v4);
putpixel(x,y,7);
delay(500);
}
//closegraph();
getch();
return 0;
}

• Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your blog? My website is in the very same area of interest as yours and my visitors would definitely benefit from a lot of the inmrofation you present here. Please let me know if this alright with you. Thanks!

2. Error occured.
I solved errors still output is not generating.

3. sham menon

wer is the pow function in the program

4. togelresultlive

I appreciate, result in I found exactly what I used to be taking a look for. Youâ€™ve ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye

http://togelresultlive.com

More from Graphics
C Program to display a line graph using midpoint line algorithm. Research Papers Projects 