Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <math.h>
- #include <graphics.h>
- void beizer(int x[],int y[]){
- double u;
- int i;
- for(u=0.0;u<1.0;u+=0.0001){
- double tx = pow((1-u), 3)*x[0] + 3*u*pow((1-u), 2)*x[1] + 3*pow(u, 3)*(1-u)*x[2]+pow(u, 3)*x[3];
- double ty = pow((1-u), 3)*y[0] + 3*u*pow((1-u), 2)*y[1] + 3*pow(u, 3)*(1-u)*y[2]+pow(u, 3)*y[3];
- putpixel(tx,ty,12);
- }
- }
- void startgraphics(){
- int gd=DETECT,gm;
- initgraph(&gd,&gm,"");
- cleardevice();
- }
- void main(){
- int i, x[4], y[4];
- startgraphics();
- for(i=0; i<4; i++){
- printf("Enter coordinates of point %d:-\n",i+1);
- scanf("%d%d", &x[i], &y[i]);
- }
- beizer(x, y);
- getch();
- closegraph();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement