#include<conio.h>
#include<graphics.h>
#include<math.h>
void initgraph()
{
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
}
void allume(float x,float y,int c)
{
putpixel(x+getmaxx()/2,(1)*y+getmaxy()/2,c);
}
void Rotation(int h,int k,int x,int y,float teta,int c)
{ int x1,y1,x2,y2;
x1=x*cos(teta)+y*sin(teta);
y1=-x*sin(teta)+y*cos(teta);
allume(h+x1,y1+k,c);
allume(h-1*x1,-1*y1+k,c);
x2=x*cos(M_PI-teta)+y*sin(M_PI-teta);
y2=-x*sin(M_PI-teta)+y*cos(M_PI-teta);
allume(h+x2,-1*y2+k,c);
allume(h-1*x2,y2+k,c);
}
void ellipse(int h,int k,long a,long b,float teta,int c)
{ long x=0,y=b;
while(x<=a){
y=b*sqrt(a*a-x*x)/a;
Rotation(h,k,x,y,teta,c);
x=x+1;
}
}
void Dessin(int h,int k,long r,long a,long b,int ce,int cc)
{
long x0,y0;
ellipse(h,k,r,r,0.0,cc);
for(float teta=0.0;teta<2*M_PI;teta+=M_PI/6)
{
x0=(r+a)*cos(teta)+k*sin(teta);
y0=-(r+a)*sin(teta)+k*cos(teta);
ellipse(x0,y0,a,b,teta,ce);
}
}
void main()
{
initgraph();
//setfillstyle(1,4);
//fillellipse(320,240,30,30);
Dessin(0,0,30,60,20,10,4);
getch();
closegraph();
}