import java.io.*;



public class M3x3
{
    
public double M[][];
    
public M3x3(double theta) // constructs a rotational matrix 
    {
	M=new double[3][3];
	M[0][0]=Math.cos(theta);
	M[0][1]=(-Math.sin(theta));
	M[0][2]=0;
	M[1][0]=-M[0][1];
	M[1][1]=M[0][0];
	M[1][2]=0;
	M[2][0]=0;
	M[2][1]=0;
	M[2][2]=1;
    }
    
public M3x3(double a, double b, char ch) // constructs a scale/translate
    {                                    // matrix depending on the third argument
	M=new double[3][3];
	if(ch=='t' || ch=='T')
	    {
		M[0][0]=1;
		M[0][1]=0;
		M[0][2]=a;
		M[1][0]=0;
		M[1][1]=1;
		M[1][2]=b;
		M[2][0]=0;
		M[2][1]=0;
		M[2][2]=1;
	    }
	else if(ch=='s' || ch=='S')
	    {
		M[0][0]=a;
		M[0][1]=0;
		M[0][2]=0;
		M[1][0]=0;
		M[1][1]=b;
		M[1][2]=0;
		M[2][0]=0;
		M[2][1]=0;
		M[2][2]=1;
	    }
	else if(ch=='i' || ch=='I')
	    {
		M[0][0]=1;
		M[0][1]=0;
		M[0][2]=0;
		M[1][0]=0;
		M[1][1]=1;
		M[1][2]=0;
		M[2][0]=0;
		M[2][1]=0;
		M[2][2]=1;
	    }
    }
    
public M3x3(M3x3 a, M3x3 b)
    {
	M=new double[3][3];
	for(int i=0; i<3; i++)
	    for(int j=0; j<3; j++)
		{
		    M[i][j]=0;
		    for(int k=0; k<3; k++)
			M[i][j]+=(a.M[i][k]*b.M[k][j]);
		}
    }
    
public void dump()
    {
	for(int i=0; i<3; i++)
	    {
		for(int j=0; j<3; j++)
		    {
			System.out.print(M[i][j]);
			System.out.print(" ");
		    }
		System.out.println();
	    }
	System.out.println();
    }
}

