Commit 949eb2b1 authored by Jalay 's avatar Jalay

Delete BEZ.C

parent 0895d3b8
#include <graphics.h>
#include <conio.h>
#include <stdio.h>
double bez(double t,int p[],int a,int b)
{
if(a==b)
return p[a];
else
return (1-t)*bez(t,p,a,b-1)+t*bez(t,p,a+1,b);
}
void main(){
double step,i,t;
float size;
int x0=10,n,y0=10,x1=100,y1=200,x2=300,y2=200,x3=100,y3=100,x,y;
int arrx[10],arry[10];
int gd=DETECT,gm;
clrscr();
printf("enter the order of the curve:");
scanf("%d",&n);
printf("enter the control points:");
for(i=0;i<=n;i++)
{
scanf("%d %d",&arrx[i],&arry[i]);
}
initgraph(&gd,&gm,"..\\bgi");
setcolor(GREEN);
step=500;
size=1.0/(double)step;
moveto(arrx[0],480-arry[0]);
for(i=1;i<step;i++){
t=size*(double)i;
x=bez(t,arrx,0,n);
y=bez(t,arry,0,n);
lineto(x,480-y);
}
setcolor(CYAN);
moveto(arrx[0],480-arry[0]);
for(i=0;i<=n;i++)
{
lineto(arrx[i],480-arry[i]);
}
// lineto(arrx[0],480-arry[0]);
for(i=0;i<=n;i++)
{
putpixel(arrx[i],480-arry[i],YELLOW);
}
getch();
closegraph();
restorecrtmode();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment