Friday 27 September 2013

BRESENHAM'S ELLIPSE DRAWING ALGORITHM - Computer Graphics - Lab Experiment - IT Department - Final Year

EXP 1.C


#include
#include
#include
#include
#include
void plotellipse(float,float,float,float);
class ellip{
private:float a,b,xc,yc,x,y,k;
public:void getdata();
void plot();
};
void ellip::getdata(){
cout<<"\nMIDPOINT ELLIPSE DRAWING ALGORITHM\n";
cout<<"\nEnter the values for a,b,xc,yc\n";
cin>>a>>b>>xc>>yc;
}
void ellip::plot()
{
xc=getmaxx()/2;
yc=getmaxy()/2;
line(0,yc,xc*2,yc);
line(xc,0,xc,yc*2);
for(k=0;k<360 k="" p=""> {
x=a*cos((k*3.14)/180);
y=b*sin((k*3.14)/180);
plotellipse(xc,yc,x,y);
}}
void main()
{
ellip p;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
gotoxy(2,2);
p.getdata();
settextstyle(0,2,8);
outtextxy(325,5,"ELLIPSE");
p.plot();
getch();
closegraph();
}void plotellipse(float xc,float yc,float x,float y)
{ int i,j;
long a1,a2;
getaspectratio(&i,&j);
a1=(long)x*(long)j/(long)i;
a2=(int)a1;
putpixel(xc+a2,yc+y,15);
putpixel(xc-a2,yc+y,15);
putpixel(xc+a2,yc-y,15);
putpixel(xc-a2,yc-y,15);
}




No comments:

Don't You Think this Awesome Post should be shared ??
| BRESENHAM'S ELLIPSE DRAWING ALGORITHM - Computer Graphics - Lab Experiment - IT Department - Final Year |
Back To Top Related Posts Plugin for WordPress, Blogger...