package matrix; public class Matrix2D { public static Matrix createMatrix2D(double a,double b,double c,double d) { Matrix ret = new Matrix(3,3); ret.setCell(a,0,0); ret.setCell(b,0,1); ret.setCell(0.0,0,2); ret.setCell(c,1,0); ret.setCell(d,1,1); ret.setCell(0.0,1,2); ret.setCell(0.0,2,0); ret.setCell(0.0,2,1); ret.setCell(1.0,2,2); return ret; } public static Matrix createMatrix1D(double x,double y) { Matrix ret = new Matrix(1,3); ret.setCell(x,0,0); ret.setCell(y,0,1); ret.setCell(1.0,0,2); return ret; } public static Matrix RotateMatrix(double kakudo) { double kaku =(Math.PI)*(kakudo/180.0); return createMatrix2D(Math.cos(kaku),(-1*Math.sin(kaku)),Math.sin(kaku),Math.cos(kaku)); } public static Matrix MoveMatrix(double x,double y) { Matrix mat = createMatrix2D(1.0,0.0, 0.0,1.0); mat.setCell(x,0,2); mat.setCell(y,1,2); return mat; } public static Matrix PositionMatrix(double x,double y) { Matrix pos = createMatrix1D(x,y); return pos.doTranspos(); } public static Matrix rotate(Matrix mat,double kakudo) { double kyo = Math.sqrt(mat.getCell(0,0)*mat.getCell(0,0) + mat.getCell(0,1)*mat.getCell(0,1)); System.out.println("kyo"+kyo); Matrix ma =Matrix2D.RotateMatrix(kakudo); /* System.out.println( ma.getCell(0,0)+" "+ ma.getCell(0,1)+" "+ ma.getCell(1,0)+" "+ ma.getCell(1,1)+" " ); */ return ma.innerProduct(mat); } public Matrix scale() { return null; } public static void main(String args[]) { Matrix mat= Matrix2D.createMatrix2D(1.0,1.0,1.0,1.0); Matrix mat0= Matrix2D.createMatrix2D(1.0,2.0,3.0,4.0); System.out.println( mat.getCell(0,0)+" "+ mat.getCell(0,1)+" "+ mat.getCell(1,0)+" "+ mat.getCell(1,1)+" " ); mat=Matrix2D.rotate(mat,30.0); System.out.println( mat.getCell(0,0)+" "+ mat.getCell(0,1)+" "+ mat.getCell(1,0)+" "+ mat.getCell(1,1)+" " ); } }