Sunday 22 March 2015

translation in cg

#include<stdio.h>
#include<conio.h>
#include<graphics.h>

void main()
{
int exp[5][5],trs[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("\n expression matrix is");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("\t %d",exp[i][j]);
}
}
printf("\n enter the value m");
scanf("%d",&n);
printf("\n enter the value of tx and ty");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
 if(i==2&j!=2)
 {
 scanf("%d",&trs[i][j]);
 }
 }
 }
 printf("\n trs matrix is");
 for(i=0;i<3;i++)
 {
 printf("\n");
 for(j=0;j<3;j++)
 {
 printf("\t %d",trs[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]*trs[k][j];
   }
   }
   }
   printf("\n the resultant matrix is:");
   for(i=0;i<3;i++)
   {
   for(j=0;j<3;j++)
   {
    printf("\t %d",res[i][j]);
     }
     }
     clrscr();

     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