I need to draw characters like alpha(α) beta(β) and gamma(γ) using bezier curve. I am not able to find the correct control points combination. So should I make any changes in the program or should I change it completely.
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<stdlib.h>
#include<process.h>
#include<conio.h>
#include<math.h>
#define POINTS 10
int x[POINTS],y[POINTS],no,endl,i,k;
double factorial(double number)
{
double product=1;
for(i=1;i<number;i++)
product*=i;
return product;
}
void getData()
{
printf("enter no. of points:");
scanf("%d",&no);
printf("enter points:%d",endl);
for(i=0;i<no;i++)
{
printf("x=%d ",i);
scanf("%d",&x[i]);
printf("y=%d ",i);
scanf("%d", &y[i]);
}
for(i=1;i<no;i++)
line(x[i-1],y[i-1],x[i],y[i]);
}
void Bezier()
{
double b=0,f=0;
double u=0.0001;
while(u<=1)
{
double xu=0,yu=0;
for(k=0;k<=no;k++)
{
f=factorial(no)/(factorial(k)*factorial(no-k));
b=pow(u,k)*pow((1-u),(no-k));
xu+=x[k]*f*b;
yu+=y[k]*f*b;
}
putpixel(xu,yu,WHITE);
u+=0.0001;
}
}
void main()
{
int gd=DETECT,gm;
clrscr();
initgraph(&gd,&gm,"C:\\TC\\BGI");
getData();
no--;
Bezier();
getch();
closegraph();
}