Tuesday 17 March 2015

program for scaling in cg

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int exp[5][5],scl[5][5],res[5][5],i,n,j,k;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c://tc//bgi");
printf("\n neter the number of size of square matrix");
scanf("%d",&n);
printf("\n ente the points of polygon:");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&exp[i][j]);
}
}
printf("the matrix is:");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t %d",exp[i][j]);
}
}

printf("\n enter element of scl mt");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&scl[i][j]);
}
}
printf("the matrix is:");
for(i=0;i<3;i++)
{

for(j=0;j<3;j++)
{
printf("\t %d",scl[i][j]);
}
}
printf("\n result");
for(i=0;i<3;i++)

for(j=0;j<3;j++)
{
res[i][j]=0;
for(k=0;k<3;k++)
{
res[i][j]=res[i][j]+exp[i][k]*scl[k][j];
}
}

printf("\n the resultant matrix is:");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",res[i][j]);
}
}
clrscr();
setcolor(6);
line(exp[0][0],exp[0][1],exp[1][0],exp[1][1]);
line(exp[0][0],exp[0][1],exp[2][0],exp[2][1]);
line(exp[1][0],exp[1][1],exp[2][0],exp[2][1]);
line(res[0][0],res[0][1],res[1][0],res[1][1]);
line(res[0][0],res[0][1],res[2][0],res[2][1]);
line(res[1][0],res[1][1],res[2][0],res[2][1]);
getch();
closegraph();
}

No comments:

Post a Comment