Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<graphics.h>
- int i,x,y,tx,ty,sx,sy,angle=10,xmax,ymax,xmid,ymid,op=1;
- float p1[10]={50,50,100,50,100,100,50,100,50,50};
- float b[3][3]={1,0,0,0,1,0,0,0,1};
- int c[1][1];
- float a[1][1];
- void trans(){
- printf("\nEnter x translation: ");
- scanf("%d",&tx);
- printf("\nEnter y translation: ");
- scanf("%d",&ty);
- b[0][0]=1;b[0][1]=0;b[0][2]=0;b[1][0]=0;
- b[1][1]=1;b[1][2]=0;b[2][0]=tx;b[2][1]=ty;b[2][2]=1;
- }
- void main(){
- int gd=DETECT,gm;
- clrscr();
- initgraph(&gd, &gm, "C:\\tc\\bgi");
- trans();
- xmax=getmaxx();
- ymax=getmaxy();
- xmid=xmax/2;
- ymid=ymax/2;
- setcolor(1);
- line(xmid,0,xmid,ymax);
- line(0,ymid,xmax,ymid);
- setcolor(4);
- for(i=0;i<8;i=i+2)
- line(p1[i]+xmid,ymid-p1[i+1],xmid+p1[i+2],ymid-p1[i+3]);
- for(i=0;i<9;i=i+2){
- a[0][0]=p1[i];a[0][1]=p1[i+1];
- c[0][0]=a[0][0]*b[0][0]+a[0][1]*b[1][0]+b[2][0];
- c[0][1]=a[0][0]*b[0][1]+a[0][1]*b[1][1]+b[2][1];
- p1[i]=c[0][0];
- p1[i+1]=c[0][1];
- }
- setcolor(15);
- for(i=0;i<8;i=i+2)
- line(p1[i]+xmid,ymid-p1[i+1],xmid+p1[i+2],ymid-p1[i+3]);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement