Sunday, October 16, 2011

C Graphics : Translation in 2D transformation


void transalate(int *x,int *y,int tx,int ty)

{

int trans[3][3]={1,0,0,0,1,0,0,0,1};

int a[3][1]={0,0,1};

int c[3][1];

int i,j,k;

trans[0][2]=tx;

trans[1][2]=ty;

a[0][0]=*x;

a[0][1]=*y;



for(i=0;i<3;i++)

{

for(j=0;j<1;j++)

{

c[i][j]=0;

for(k=0;k<3;k++)

{

c[i][j]+=trans[i][k]*a[k][j];

}

}

}



*x=c[0][0];

*y=c[1][0];



}

No comments:

Post a Comment