Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

WRITE A PROGRAM TO PERFORM 2D TRANSFORMATION ON A SHIP


#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void makeship(int x[8],int y[8])
{
line(x[0],y[0],x[1],y[1]);
line(x[0],y[0],x[2],y[2]);
line(x[3],y[3],x[4],y[4]);
line(x[4],y[4],x[5],y[5]);
line(x[5],y[5],x[6],y[6]);
line(x[6],y[6],x[3],y[3]);
line(x[1],y[1],x[7],y[7]);
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
int tx;
int x[8],int y[8];
x[0]=150;        y[0]=100;
x[1]=210;        y[1]=320;
x[2]=150;                                    y[2]=200;
x[3]=100;                                    y[3]=200;
x[4]=300;                                    y[4]=300;
x[5]=250;                                    y[5]=300;
x[6]=150;                                    y[6]=300;
x[7]=230;                                    y[7]=320;
makeship(x,y);
getch();
  // clear Viewpoint();
cout<<"/t Enter no of translation+:";
cin>>tx;
for(int t=0;t<tx;t++)
{
for(int i=0;i<8;i++)
{
x[i]=x[i]+100;
y[i]=y[i]+100;
}
makeship(x,y);
delay(100);
}
getch();
Closegraph();
}


Previous
Next Post »