//// scaling program////
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<graphics.h>
void matrixmulti(int
translate[3][3],int vertex[3][5],int result[3][5]);
void main()
{
int
gd=DETECT,gm,errorcode;
initgraph(&gd,&gm,"\\tc\\bgi");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics
ERROR!: %s",grapherrormsg(errorcode));
printf("\nPress
any Key .......");
getch();
exit(1);
}
setbkcolor(2);
int
vertex[3][5]={{100,100,200,200,100},
{100,200,200,100,100},
{1,1,1,1,1}};
for(int
i=0;i<4;i++)
{
setcolor(BLUE);
line(vertex[0][i],vertex[1][i],vertex[0][i+1],vertex[1][i+1]);
}
printf("SCALE
X=");
int
sx,sy;
scanf("%d",&sx);
printf("SCALE
Y:=");
scanf("%d",&sy);
int
translate[3][3]={{2,0,0},{0,1,0},{0,0,1}};
translate[0][0]=sx;
translate[1][1]=sy;
printf("Press
any key for the translated line.....\n");
getch();
int
result[3][5];
matrixmulti(translate,vertex,result);
for(i=0;i<4;i++)
{
setcolor(YELLOW);
line(result[0][i],result[1][i],result[0][i+1],result[1][i+1]);
}
getch();
closegraph();
}
void matrixmulti(int
translate[3][3],int vertex[3][5],int result[3][5])
{
for(int
i=0;i<=3;i++)
{
for(int
j=0;j<=5;j++)
{
result[i][j]=0;
for(int k=0;k<=3;k++)
result[i][j]+=translate[i][k]*vertex[k][j];
}
}
}