Friday 27 September 2013

2D Transformation - Translation | Computer Graphics Lab Manual | IT department | Final Year




#include
#include
#include
void main(){
int gd=DETECT,gm;
int x1=0,x2=0,y1=0,y2=0,tx=0,ty=0,x,y,a,b;
char q[10];
int i,j,maxx,maxy;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
maxx=getmaxx();
maxy=getmaxy();
printf("\n\t2D Transformation-Translation");
printf("\nEnter values for (x1,y1) and (x2,y2):\t");
scanf("%d%d%d%d",&x1,&y1,&x1,&y2);
printf("\nEnter the translating factor:");
scanf("%d%d",&tx,&ty);
cleardevice();
line(50,maxy-35,maxx-50,maxy-35);
outtextxy(600,400,"x");
line(50,10,50,maxy-35);
outtextxy(45,0,"y");
for(i=30;i<=450;i+=30)
{sprintf(q,"%3d",i);
outtextxy(25+i,450,q);}
for(j=30;j<450 j="" p=""> {sprintf(q,"%3d",j);
outtextxy(25,450-j,q);}
x=x1+50;
y=450-y1;
a=x2+50;
b=450-y2;
setlinestyle(SOLID_LINE,0X0011,NORM_WIDTH);
rectangle(x,y,a,b);
  x1+=tx;
y1+=ty;
x2+=tx;
y2+=ty;
x1=x1+50;
y1=450-y1;
x2=x2+50;
y2=450-y2;
setlinestyle(DOTTED_LINE,0X0011,NORM_WIDTH);
rectangle(x1,y1,x2,y2);
getch();
closegraph();}




No comments:

Don't You Think this Awesome Post should be shared ??
| 2D Transformation - Translation | Computer Graphics Lab Manual | IT department | Final Year |
Back To Top Related Posts Plugin for WordPress, Blogger...