#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <graphics.h>
#include <math.h>
#define ROUND(a) ((int)(a+0.5))
void plot_ellipse(int,int,int,int);
int xc,yc,rx,ry;
void main()
{
int rx2,ry2,twoRx2,twoRy2;
int i,j,x,y,p,px,py;
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
printf("Enter the co-ordinates of the centre:\n");
scanf("%d%d",&xc,&yc);
printf("Please enter the radius of the ellipse :\n");
scanf("%d%d",&rx,&ry);
cleardevice();
rx2=rx*rx;
ry2=ry*ry;
twoRx2=2*rx2;
twoRy2=2*ry2;
x=0; y=ry;
px=0; py=twoRx2*y;
plot_ellipse(xc,yc,x,y);
p=ROUND(ry2-(rx2*ry)+(0.25*rx2));
while(px<py)
{
x++;
px+=twoRy2;
if(p<0)
p+=ry2+px;
else {
y--;
py-=twoRx2;
p+=ry2+px-py;
}
plot_ellipse(xc,yc,x,y);
}
p=ROUND(ry2*(x+0.5)*(x+0.5)+rx2*(y-1)*(y-1)-rx2*ry2);
while(y>0)
{
y--;
py-=twoRx2;
if(p>0)
p+=rx2-py;
else
{
x++;
px+=twoRy2;
p+=rx2-py+px;
}
plot_ellipse(xc,yc,x,y);
}
getch();
}
void plot_ellipse(int xc,int yc,int x,int y)
{
putpixel(xc+x,yc+y,4);
putpixel(xc+x,yc-y,4);
putpixel(xc-x,yc+y,4);
putpixel(xc-x,yc-y,4);
}
4 comments:
homemade viagra buying viagra online free viagra without prescription buy viagra in canada viagra buy viagra from india buy cheap viagra online uk cheap cheap viagra viagra results free viagra samples before buying buy viagra australia viagra larger forever levitra vs viagra non prescription viagra
you have a nice site. thanks for sharing this site. you can download lots of ebook from here
http://feboook.blogspot.com
you have a nice site. thanks for sharing this site. you can download lots of ebook from here
http://feboook.blogspot.com
Nice fill someone in on and this fill someone in on helped me alot in my college assignement. Say thank you you for your information.
Post a Comment