Sunday, October 16, 2011

C Graphics : Scaling in 2D transformation


void scale(int *x,int *y,double sx,double sy)

{

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

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

double c[3][1];

int i,j,k;

trans[0][0]=sx;

trans[1][1]=sy;

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