Sunday, October 16, 2011

C Graphics : Shearing in 2D transformation


void shearing(int *x,int *y,double shx,double shy)

{

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][1]=shx;

trans[1][0]=shy;

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