http://www.programmersheaven.com/zone3/i...
http://www.planet-source-code.com/vb/def...
http://freeware.brothersoft.com/software...
Write a C++ code for Mid point circle algorthim and mid point Ellipse algorthim?
#include%26lt;iostream.h%26gt;
#include%26lt;graphics.h%26gt;
#include%26lt;math.h%26gt;
#include%26lt;conio.h%26gt;
#include%26lt;stdio.h%26gt;
#include%26lt;process.h%26gt;
#include %26lt;stdlib.h%26gt;
#include%26lt;dos.h%26gt;
int convertx(int k)
{
return(320+k);
}
int converty(int k)
{
return(240-k);
}
int convertxc(int k)
{
return(320+k);
}
int convertyc(int k)
{
return(240-k);
}
void axis();
int circlemid(int,int,int);
void plotpoint();
void main()
{
int gdriver=DETECT,gmode;
initgraph(%26amp;gdriver,%26amp;gmode,"c:\\tc1\\bgi"...
float xc,yc;
float r;
while(1)
{
cout%26lt;%26lt;"\n Enter The Center Of The Circle : ";
cin%26gt;%26gt;xc%26gt;%26gt;yc;
cout%26lt;%26lt;"\n Enter the Radius Of The Circle: ";
cin%26gt;%26gt;r;
circlemid(xc,yc,r);
cout%26lt;%26lt;"\n Do you want to continue ('y' or 'Y') : ";
char c;
c=getch();
if(c=='y' || c=='Y')
break;
}
}
void axis()
{
setcolor(1);
line(320,0,320,480);
line(0,240,640,240);
}
void plotpoint(int xc,int yc,int x1,int y1)
{
delay(50);
putpixel(convertxc(xc)+x1,convertyc(yc)+...
putpixel(convertxc(xc)-x1,convertyc(yc)+...
putpixel(convertxc(xc)+x1,convertyc(yc)-...
putpixel(convertxc(xc)-x1,convertyc(yc)-...
putpixel(convertxc(xc)+y1,convertyc(yc)+...
putpixel(convertxc(xc)-y1,convertyc(yc)+...
putpixel(convertxc(xc)+y1,convertyc(yc)-...
putpixel(convertxc(xc)-y1,convertyc(yc)-...
}
int circlemid(int xc,int yc,int r)
{
int x,y;
x=0;
y=r;
axis();
putpixel(convertxc(xc),convertyc(yc),5);
plotpoint(xc,yc,x,y);
double p=1-r;
while(x%26lt;y)
{
if(p%26lt;0)
{
x=x+1;
p=p+2*x+1;
}
else
{
x=x+1;
y=y-1;
p=p+2*(x-y)+1;
}
plotpoint(xc,yc,x,y);
}
return(0);
}
try to follow the code rules and try on your own for developing yous coding knowldge
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment