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[4], int y[4]) { 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[0] + 3 * t * pow (1-t, 2) * x[1] + 3 * pow (t, 2) * (1-t) * x[2] + pow (t, 3) * x[3]; double yt = 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 (xt, yt, WHITE); } for (i=0; i<4; i++) putpixel (x[i], y[i], YELLOW); getch(); closegraph(); return; } void main() { int x[4], y[4]; 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); } |

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!

Error occured.

I solved errors still output is not generating.

wer is the pow function in the program