public class TransformationGeometrique { float m[][]; public TransformationGeometrique() { m = new float[4][4]; for ( int i = 0 ; i < 4 ; i++ ) for ( int j = 0 ; j < 4 ; j++ ) m[i][j] = 0.0F; for ( int i = 0 ; i < 4 ; i++ ) m[i][i] = 1.0F; } public TransformationGeometrique(TransformationGeometrique tg) { m = new float[4][4]; for ( int i = 0 ; i < 4 ; i++ ) for ( int j = 0 ; j < 4 ; j++ ) m[i][j] = tg.m[i][j]; } public TransformationGeometrique composition(TransformationGeometrique tg) { TransformationGeometrique mp = new TransformationGeometrique(); for ( int i = 0 ; i < 4 ; i++ ) for ( int j = 0 ; j < 4 ; j++ ) { mp.m[i][j] = 0.0F; for ( int k = 0 ; k < 4 ; k++ ) mp.m[i][j] += m[i][k]*tg.m[k][j]; } return(mp); } public CoordonneesHomogenes transformation(CoordonneesHomogenes p) { CoordonneesHomogenes ch = new CoordonneesHomogenes(); for ( int i = 0 ; i < 4 ; i++ ) { ch.c[i] = 0.0F; for ( int k = 0 ; k < 4 ; k++ ) ch.c[i] += m[i][k]*p.c[k]; } return(ch); } public String toString() { return(m[0][0]+" "+m[0][1]+" "+m[0][2]+" "+m[0][3]+"\n"+ m[1][0]+" "+m[1][1]+" "+m[1][2]+" "+m[1][3]+"\n"+ m[2][0]+" "+m[2][1]+" "+m[2][2]+" "+m[2][3]+"\n"+ m[3][0]+" "+m[3][1]+" "+m[3][2]+" "+m[3][3]); } }