CG=02

11. To implement for translation,rotation & scaling of
2d object
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<stdlib.h>
class triangle
{
public: void draw(int,int,int,int,int,int);
void trans(int,int,int,int,int,int);
void rotate(int,int,int,int,int,int);
void scale(int,int,int,int,int,int);
};
void main()
{
int x1,y1,x2,y2,x3,y3,ch;
int gd=DETECT,gm;
triangle t;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
cout<<"\n Enter the co-odrnates of x1 & y1 \n";
cin>>x1>>y1;
circle(x1,y1,2);
cout<<"\n Enter the coordinate of x2 & y2 \n";
cin>>x2>>y2;
circle(x2,y2,2);
cout<<"\n Enter the coordinated of x3 & y3 \n";
cin>>x3>>y3;
circle(x3,y3,2);
t.draw(x1,y1,x2,y2,x3,y3);
cout<<"\n1.Translate \n";
cout<<"\n2.Scaling \n";
cout<<"\n3.Rotation \n";
cout<<"\n4.Exit \n";
cout<<"\n Enter your choice \n";
cin>>ch;
switch(ch)
{
case 1: t.trans(x1,y1,x2,y2,x3,y3);
break;
case 2: t.scale(x1,y1,x2,y2,x3,y3);
break;
case 3: t.rotate(x1,y1,x2,y2,x3,y3);
break;
case 4: exit(0);
}
getch();
}
void triangle::draw(int x1,int y1,int x2,int y2,int x3,int y3)
{
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
}
void triangle::trans(int x1,int y1,int x2,int y2,int x3,int y3)
{
int sx,sy;
cout<<"\n Enter the translation factor ";
cin>>sx>>sy;
x1+=sx;
y1+=sy;
x2+=sx;
y2+=sy;
x3+=sx;
y3+=sy;
draw(x1,y1,x2,y2,x3,y3);
}
void triangle::scale(int x1,int y1,int x2,int y2,int x3,int y3)
{
int tx,ty;
cout<<"\n Enter the scaling factor";
cin>>tx>>ty;
x1*=tx;
y1*=ty;
x2*=tx;
y2*=ty;
x3*=tx;
y3*=ty;
draw(x1,y1,x2,y2,x3,y3);
}
void triangle::rotate(int x1,int y1,int x2,int y2,int x3,int y3)
{
int xi,yi,xp,yp;
float tx,theta;
cout<<"\n Enter the rotation angle ";
cin>>theta;
theta=(3.142/180)*theta;
xi=x1+(x2-x1)*cos(theta)-(y2-y1)*sin(theta);
yi=y1+(x2-x1)*sin(theta)+(y2-y1)*cos(theta);
xp=x1+(x3-x1)*cos(theta)-(y3-y1)*sin(theta);
yp=y1+(x3-x1)*sin(theta)+(y3-y1)*cos(theta);
draw(x1,y1,xi,yi,xp,yp);
}
OUTPUT
12.To illustrate composite transformation.
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
class trans
{
int x[4],y[4],i,rx,ry,n,tx[4],ty[4],txx,tyy;
public: void tratri(int x[],int y[],int n);
void transtrans(int x[],int y[],int n);
void transscale(int x[],int y[],int n);
void transrotate(int x[],int y[],int n);
void getpoints();
};
void trans::getpoints()
{
int ch,i,n=3;
for(i=0; i<n; i++)
{
cout<<"\n Enter vertex x["<<i<<"],y["<<i<<"]:";
cin>>x[i]>>y[i];
}
x[n]=x[0];
y[n]=y[0];
cleardevice();
do
{
gotoxy(1,1);
cout<<" Original triangle \n"<<endl;
tratri(x,y,n);
cout<<"\n Enter your choice"<<endl;
cout<<"\n1.Transformation \n2.Rotation \n.Scaling \n 4.Exit \n"<<endl;
cin>>ch;
switch(ch)
{
case 1: cleardevice();
transtrans(x,y,n);
cleardevice();
break;
case 2: cleardevice();
transrotate(x,y,n);
cleardevice();
break;
case 3: cleardevice();
transscale(x,y,n);
cleardevice();
break;
case 4: exit(0);
break;
}
}
while(ch!=4);
}
void trans::tratri(int x[4],int y[4],int n)
{
int i;
for(i=0;i<n;i++)
{
moveto(x[i],y[i]);
lineto(x[i+1],y[i+1]);
}
}
void trans::transtrans(int x[4],int y[4],int n)
{
cout<<"\n Enter the transformation vertex(tx,ty)";
cin>>txx>>tyy;
cout<<"\n Original triangle \n";
tratri(x,y,n);
for(i=0; i<=n; i++)
{
tx[i]=x[i]+txx;
ty[i]=y[i]+tyy;
}
cout<<"\n After transformation (tx,ty)"<<txx<<tyy;
tratri(tx,ty,n);
getch();
}
void trans::transrotate(int x[4],int y[4],int n)
{
int i,th;
float tet;
int xf,yf,rx[4],ry[4];
cout<<"\n Enter rotaion angle \n";
cin>>th;
tet=th*(3.142/180);
cout<<"\n Enter the points for rotaion \n";
cin>>xf>>yf;
cout<<"\n Original triangle is \n";
tratri(x,y,n);
cout<<"\n After rotation is \n";
for(i=0; i<=n; i++)
{
rx[i]=xf+(x[i]-xf)*cos(tet)+(y[i]-yf)*sin(tet);
ry[i]=yf+(y[i]-yf)*cos(tet)+(x[i]-xf)*sin(tet);
}
cout<<"\n After transformation (tx,ty)"<<txx<<tyy;
tratri(rx,ry,n);
getch();
}
void trans::transscale(int x[4],int y[4],int n)
{
int xf,yf,i;
float sx,sy;
cout<<"\n Enter scaling factor \n";
cin>>sx>>sy;
cout<<"\n Enter fixed point for scaling \n";
cin>>xf>>yf;
cout<<"\n Original triangle \n";
tratri(x,y,n);
for(i=0; i<=n; i++)
{
x[i]=xf+(x[i]-xf)*sx;
y[i]=yf+(y[i]-yf)*sy;
}
cout<<"\n After transformation (tx,ty)"<<txx<<tyy;
tratri(x,y,n);
getch();
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
trans t;
t.getpoints();
getch();
}
OUTPUT
13.To clip a line using:
i. Cohen-sutherland line clipping algorithm.
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
class line_clip
{
private: int x,y,x1,y1;
int n;
public: int code(int,int);
int x3,y3,x4,y4;
void clipploy(int,int,int,int);
void get();
};
void line_clip::get()
{
cout<<"\n Enter the start point \n";
cin>>x>>y;
cout<<"Enter the end points \n";
cin>>x1>>y1;
cout<<"Before clipping the line is..\n";
rectangle(100,100,300,200);
line(x,y,x1,y1);
getch();
cleardevice();
cout<<"\n after clipping is \n";
clipploy(x,y,x1,y1);
}
void line_clip::clipploy(int x3,int y3,int x4,int y4)
{
int c1,c2,c;
float x2,y2;
c1=code(x3,y3);
c2=code(x4,y4);
while((c1!=1)||(c2!=1))
{
c=c1;
if(c1==1)
c=c2;
if(c==3||c==33||c==21)
{
y2=y3+((y4-y3)*(100-x3))/(x4-x3);
x2=100;
}
else if(c==5||c==55||c==35)
{
x2=300;
y2=y3+((300-x3)*(y4-y3))/(x4-x3);
}
else if(c==7)
{
x2=x3+((x4-x3)*(200-y3))/(y4-y3);
y2=200;
}
else
if(c==11)
{
x2=x3+((x4-x3)*(100-y3))/(y4-y3);
y2=100;
}
if(c==c1)
{
x3=x2;
y3=y2;
c1=code(x3,y3);
}
else
{
x4=x2;
y4=y2;
c2=code(x4,y4);
}
}
rectangle(100,100,300,200);
line(x3,y3,x4,y4);
}
int line_clip::code(int x,int y)
{
int k=1;
if(x<100) k*=3;
else if(x>300)
k*=5;
else if(y>200)
k*=7;
else if(y<100)
k*=11;
return k;
}
void main()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
line_clip ob;
ob.get();
getch();
closegraph();
}
OUTPUT
14.To clip polygon using Sutherland-Hodeman polygon
clipping
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
class plyclp
{
float x[10],y[10];
int n,i;
public:int code(int,int);
void clippoly(float,float,float,float);
void get();
};
void plyclp::get()
{
int m=0;
cout<<"\n Enter the number of points";
cin>>n;
cout<<"\n Enter the coordinates points \n";
for(i=0; i<n; i++)
{
cout<<i+1<<"points:";
cin>>x[i]>>y[i];
circle(x[i],y[i],1);
}
cout<<"\n Before polygon clipping is \n";
rectangle(100,100,300,200);
for(i=0; i<n; i++)
{
m=(i+ 1)%n;
line(x[i],y[i],x[m],y[m]);
}
getch();
clrscr();
cleardevice();
cout<<"\n After polygon clipping is \n";
rectangle(100,100,300,200);
for(i=0; i<n; i++)
{
m=(i+1)%n;
clippoly(x[i],y[i],x[m],y[m]);
}
}
void plyclp::clippoy(float x3,float y3,float x4,float y4)
{
int c1,c2,c;
float x2,y2;
c1=code(x3,y3);
c2=code(x4,y4);
while((c1!=1)||(c2!=1))
{
c=c1;
if(c1==1)c=c2;
if(c==3||c==33||c==21)
{
y2=y3+((y4-y3)*(100-x3))/(x4-x3);
x2=100;
}
else if(c==5||c==55||c==35)
{
y2=y3+((y4-y3)*(300-x3))/(x4-x3);
x2=300;
}
else if(c==7)
{
x2=x3+((x4-x3)*(200-y3))/(y4-y3);
y2=200;
}
else if(c==11)
{
x2=x3+((x4-x3)*(100-y3))/(y4-y3);
y2=100;
}
if(c==c1)
{
x3=x2;
y3=y2;
c1=code(x3,y3);
}
else
{
x4=x2;
y4=y2;
c2=code(x4,y4);
}
}
line(x3,y3,x4,y4);
}
int plyclip::code(int x,int y)
{
int k=1;
if(x<100)k*=3;
else if(x>300)k*=5;
else if(y>200)k*=7;
else if(y<100)k*=11;
return k;
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
plyclp ob;
ob.get()
getch()
}
OUTPUT
13.To clip a line using:
II. To clip a aline using Liang-Barkely line cliping algorithm
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
class lineclip
{
private: double dx,dy,t0,t1;
double x0,x1,y0,y1;
public: int read(),flag;
double clippoint(double,double);
void cliped(double,double,double,double);
double clippt(double,double,double *,double *);
};
int lineclip::read()
{
cout<<"Enter the start points \n";
cin>>x0>>y0;
cout<<"\n Enter the end points \n";
cin>>x1>>y1;
cout<<"\n before clipping line is";
rectangle(100,100,300,200);
line(x0,y0,x1,y1);
getch();
cleardevice();
cout<<"\n After clipping line is \n";
cliped(x0,y0,x1,y1);
return 0;
}
void lineclip::cliped(double x0,double y0,double x1,double y1)
{
dx=x1-x0;
dy=y1-y0;
if(dx==0 && dy==0 && clippoint (x0,y0))
flag=1;
else
{
t0=0.0; t1=1.0;
if(clippt(dx,100-x0,&t0,&t1))
if(clippt(-dx,x0-300,&t0,&t1))
if(clippt(dy,100-y0,&t0,&t1))
if(clippt(-dy,y0-200,&t0,&t1))
{
x1=x0+t1*dx;
y1=y0+t1*dy;
}
if(t0>0)
{
x0+=t0*dx;
y0+=t0*dy;
}
}
rectangle(100,100,300,200);
line(x0,y0,x1,y1);
}
double lineclip::clippt(double denum,double num,double *t0,double *t1)
{
double t;
if(denum>0)
{
t=num/denum;
if(t>*t1)
return(0);
else if(t>*t0)
*t0=t;
}
else if(denum<0)
{
t=num/denum;
if(t<*t0)
return(0);
else
*t1=t;
}
else if(num>0)
return(0);
return(1);
}
double lineclip::clippoint(double x,double y)
{
int k=1;
if(k<100)
k*=3;
else if(x>300) k*=5;
else if(y<100) k*=11;
return k;
}
void main()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
lineclip ob;
ob.read();
getch();
}
OUTPUT
15.To draw:
i.To implement Bezier curve
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
int x,y,z;
void main()
{
float u;
int gd,gm,ymax,i,n,c[4][3];
for(i=0; i<4; i++)
{
c[i][0]=0;
c[i][1]=0;
}
printf("\n\n Enter Four points : \n\n");
for(i=0; i<4; i++)
{
printf("\t x%d y%d: ",i,i);
scanf("%d%d",&c[i][0],&c[i][1]);
}
c[4][0]=c[0][0];
c[4][1]=c[0][1];
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
ymax=480;
setcolor(13);
for(i=0; i<3; i++)
{
line(c[i][0],ymax-c[i][1],c[i+1][0],ymax-c[i+1][1]);
}
setcolor(3);
n=3;
for(i=0; i<=40; i++)
{
u=(float)i/40.0;
bezier(u,n,c);
if(i==0)
{
moveto(x,ymax-y);
}
else
{
lineto(x,ymax-y);
}
getch();
}
getch();
}
bezier(u,n,p)
float u;
int n;
int p[4][3];
{
int j;
float v,b;
float blend(int,int,float);
x=0; y=0; z=0;
for(j=0; j<=n; j++)
{
b=blend(j,n,u);
x=x+(p[j][0]*b);
y=y+(p[j][1]*b);
z=z+(p[j][2]*b);
}
}
float blend(int j,int n,float u)
{
int k;
float v,blend;
v=c(n,j);
for(k=0; k<j; k++)
{
v*=u;
}
for(k=1; k<=(n-j); k++)
{
v*=(1-u);
}
blend=v;
return(blend);
}
c(int n,int j)
{
int k,a,c;
a=1;
for(k=j+1; k<=n; k++)
{
a*=k;
}
for(k=1; k<=(n-j); k++)
{
a=a/k;
}
c=a;
return(c);
}
OUTPUT
16.To animate rolling boll on a flat surface.
#include<iostream.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
#include<dos.h>
class boll
{
float x,y,radius,pinx,piny,color;
public: void draw(int,int,int,int);
void roll(int);
};
void boll::draw(int xpos,int ypos,int r,int clr)
{
x=xpos;
y=ypos;
radius=r;
pinx=x+radius;
piny=y;
color=clr;
setcolor(color);
circle(x,y,radius);
getch();
}
void boll::roll(int dist)
{
float a,b,theta;
setcolor(getbkcolor());
circle(x,y,radius);
a=pinx;
b=piny;
theta=(float)dist/radius;
pinx=x+(a-x)*cos(theta)-(b-y)*sin(theta);
piny=x+(a-x)*sin(theta)-(b+y)*cos(theta);
x+=dist;
if(x>getmaxx()+radius)
{
x=-radius;
pinx=x+radius;
pinx=y;
}
setcolor(color);
circle(x,y,radius);
getch();
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
boll b1;
settextstyle(1,0,3);
// outtextxy(10,10);
cout<<"\n Animation of a rolling boll on a flat surface ";
b1.draw(100,200,50,BLUE);
line(5,252,639,252);
while(!kbhit())
{
b1.roll(3);
delay(10);
}
getch();
}
OUTPUT
17. To animate swinging pendulum.
#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
#include<process.h>
int cx=300,cy=100,r=300;
int x=0,y,p;
int path(int dtn)
{
int x1,y1;
setcolor(15);
if(x>=y)
{
return 0;
}
cleardevice();
if(dtn==1)
{
circle(cx+x,cy+y,20);
line(cx,cy,cx+x,cy+x);
}
else
{
circle(cx-x,cy+y,20);
line(cx,cy,cx-x,cy+y);
}
delay(10);
if(kbhit())
exit(0);
x++;
if(p<0)
p+=2*x+1;
else
{
y--;
p+=2*(x-y)+1;
}
x1=x;
y1=y;
path(dtn);
cleardevice();
if(dtn==1)
{
circle(cx+x1,cy+y1,20);
line(cx,cy,cx+x1,cy+y1);
}
else
{
circle(cx-x1,cy+y1,20);
line(cx,cy,cx-x1,cy+y1);
}
delay(10);
if(kbhit())
exit(0);
}
void main()
{
int gd=DETECT,gm=DETECT;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
putpixel(300,100,41);
while(1)
{
x=0; y=r; p=1-r;
path(1);
x=0; y=r; p=1-r;
path(0);
}
getch();
}
OUTPUT
18. To animate raotaing the arm with certain degrees of
freedom
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
class arm
{
int i;
float sx,dy;
public: void getdata(void);
};
void arm::getdata()
{
float x=0,y=0,th=(3.142/180);
cleardevice();
setcolor(40);
rectangle(100,200,200,200);
rectangle(125,100,175,50);
setcolor(40);
circle(160,60,5);
circle(140,66,5);
rectangle(120,300,105,200);
rectangle(155,300,175,200);
for(i=0; i<=120; i++)
{
setcolor(0);
circle(225,81,10);
line(150,165,260+x,165+y);
line(150,190,260+x,190+y);
line(260,165+y,260,190+y);
rectangle(100,100,200,200);
line(150,165,100,100);
x=4*sin(i*th);
y=150*sin(i*th);
setcolor(15);
circle(255,81,10);
line(150,165,260+x,165+y);
line(150,190,260+x,190+y);
line(260,165+y,260+x,190+y);
rectangle(100,100,200,200);
line(150,165,100,100);
line(150,190,100,130);
delay(150);
getch();
}
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
arm ob;
setcolor(400);
ob.getdata();
getch();
}
OUTPUT
19. Animation of moment of Hour hand, minute hand
and second’s hand of clock
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
class clock
{
float th;
int hx,hy,mx,my,sx,sy,cx,cy,h,m,s;
public: void next(int *x,int *y);
void display(void);
void update(void);
clock();
};
clock::clock()
{
cx=cy=250;
hx=mx=sx=cx;
hy=cy-50;
my=cy-60;
sy=cy-70;
h=m=s=0;
th=(3.142/30.0);
}
void clock::display()
{
cleardevice();
outtextxy(100,100,"animation of a wallclock");
setcolor(1);
setcolor(5);
setlinestyle(0,0,3);
line(cx,cy,hx,hy);
setcolor(GREEN);
line(cx,cy,mx,my);
setcolor(RED);
setlinestyle(0,0,1);
line(cx,cy,sx,sy);
setcolor(YELLOW);
circle(cx,cy,100);
circle(cx,cy,3);
outtextxy(cx-5,160,"12");
outtextxy(cx+40,170,".");
outtextxy(cx+70,205,".");
outtextxy(cx+85,245,"3");
outtextxy(cx+70,285,".");
outtextxy(cx+40,320,".");
outtextxy(cx-5,330,"6");
outtextxy(cx-70,285,".");
outtextxy(cx-40,320,".");
outtextxy(cx-85,245,"9");
outtextxy(cx-70,205,".");
outtextxy(cx-40,170,".");
}
void clock::update()
{
next(&sx,&sy);
s=(s+1)%60;
if(s==0)
{
next(&mx,&my);
m=(m+1)%12;
if(m==0)
{
next(&hx,&hy);
h=(h+1)%60;
}
}
display();
}
void clock::next(int *x,int *y)
{
int a,b;
a=*x;
b=*y;
*x=cx+(a-cx)*cos(th)-(b-cy)*sin(th);
*y=cy+(a-cx)*sin(th)+(b-cy)*cos(th);
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
clock ob;
while(!kbhit())
{
ob.display();
ob.update();
delay(200);
}
getch();
}
OUTPUT
20. Revolation of Earth around the Sun and Moon
around the Earth.
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
class revo
{
float x,y,x1,y1,x2,y2;
public: void draw(void);
};
void revo::draw()
{
static int th,th1;
outtextxy(10,10,"moon arround earth & earth arround sun");
x=320; y=240;
float pi=3.142/180;
while(!kbhit())
{
setcolor(WHITE);
setcolor(12);
circle(x,y,50);
outtextxy(x-10,y-15,"SUN");
th1+=1;
th+=20;
x1=x+165*sin(th1*pi);
y1=y+165*cos(th1*pi);
x2=x1+70*sin(th*pi);
y2=y1+70*cos(th*pi);
setcolor(YELLOW);
circle(x1,y1,30);
setcolor(7);
circle(x2,y2,23);
outtextxy(x1-18,y1-15,"EARTH");
outtextxy(x2-17,y2-18,"MOON");
if(th1>=360)
{
th=0;
th1=0;
}
delay(200);
clearviewport();
}
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
revo ob;
ob.draw();
setcolor(WHITE);
getch();
closegraph();
}
OUTPUT
21. Graphics program in which three balls move in
three concentric oval orbits without ever colliding.
#define R 5
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
#include<stdlib.h>
void main()
{
void orbit(void);
int d=DETECT,m;
initgraph(&d,&m,"e:\tcc\bgi");
float xx,yy,aa=15,bb=50,x,y,X,Y,a=34,b=0,A=100,B=60,ex,sq;
setcolor(14);
// orbit();
for(float i=0;i<=720;i+=.1)
{
x=a*cos(i+10)-a*sin(i+10);
y=b*sin(i+10)+a*cos(i+10);
X=A*cos(i+20)-B*sin(i+20+90);
Y=B*sin(i+20)+B*cos(i+20+90);
xx=aa*cos(i);
yy=bb*sin(i);
setcolor(14);
setfillstyle(1,14);
circle(x+100,y+100,R);
floodfill(x+100,y+100,14);
setcolor(14);
setfillstyle(1,14);
circle(xx+100,yy+100,R);
floodfill(xx+100,yy+100,14);
setcolor(14);
setfillstyle(1,14);
circle(X+100,Y+100,R);
floodfill(X+100,Y+100,14);
putpixel(X+100,Y+100,4);
delay(100);
setcolor(0);
setfillstyle(1,0);
circle(x+100,y+100,R);
floodfill(x+100,y+100,0);
setcolor(0);
setfillstyle(1,0);
circle(xx+100,yy+100,R);
floodfill(xx+100,yy+100,0);
setcolor(0);
setfillstyle(1,0);
circle(X+100,Y+100,R);
floodfill(X+100,Y+100,0);
if(kbhit())
exit(1);
orbit();
}
getch();
}
void orbit()
{
for(float i=0;i<=60;i+=1)
{
float xx,yy,aa=15,bb=50,x,y,X,Y,a=34,b=0,A=100,B=60,ex,sq;
x=a*cos(i)-a*sin(i);
y=b*sin(i)+a*cos(i);
X=A*cos(i)-B*sin(i+90);
Y=B*sin(i)+B*cos(i+90);
xx=aa*cos(i);
yy=bb*sin(i);
putpixel(x+100,y+100,14);
putpixel(X+100,Y+100,14);
putpixel(xx+100,yy+100,14);
}
}
OUTPUT