@Test public void testInverse() { Matrix33 matrix=Matrix33.makeTranslate(3, 4).multiply(Matrix33.makeScale(10,3)); Matrix33 IM=matrix.inverse(); Matrix33 R=matrix.multiply(IM); assertTrue(1==R.get(0,0)); assertTrue(0==R.get(0,1)); assertTrue(0==R.get(0,2)); assertTrue(0==R.get(1,0)); assertTrue(1==R.get(1,1)); assertTrue(0==R.get(1,2)); assertTrue(0==R.get(2,0)); assertTrue(0==R.get(2,1)); assertTrue(1==R.get(2,2)); }
public Matrix33 inverse() { double det = this.determinant(); if ( det == 0.0 ) throw new RuntimeException("This matrix is not invertable"); Vector3 v0 = new Vector3(m[0][0], m[1][0], m[2][0]); Vector3 v1 = new Vector3(m[0][1], m[1][1], m[2][1]); Vector3 v2 = new Vector3(m[0][2], m[1][2], m[2][2]); Vector3 t0 = v1.cross(v2); Vector3 t1 = v2.cross(v0); Vector3 t2 = v0.cross(v1); double oneOverDet = 1.0 / det; return new Matrix33 ( oneOverDet * t0.getX(), oneOverDet * t0.getY(), oneOverDet * t0.getZ(), oneOverDet * t1.getX(), oneOverDet * t1.getY(), oneOverDet * t1.getZ(), oneOverDet * t2.getX(), oneOverDet * t2.getY(), oneOverDet * t2.getZ()); }
Matrix33 { public Matrix33 inverse() { double det = this.determinant(); if ( det == 0.0 ) throw new RuntimeException("This matrix is not invertable"); Vector3 v0 = new Vector3(m[0][0], m[1][0], m[2][0]); Vector3 v1 = new Vector3(m[0][1], m[1][1], m[2][1]); Vector3 v2 = new Vector3(m[0][2], m[1][2], m[2][2]); Vector3 t0 = v1.cross(v2); Vector3 t1 = v2.cross(v0); Vector3 t2 = v0.cross(v1); double oneOverDet = 1.0 / det; return new Matrix33 ( oneOverDet * t0.getX(), oneOverDet * t0.getY(), oneOverDet * t0.getZ(), oneOverDet * t1.getX(), oneOverDet * t1.getY(), oneOverDet * t1.getZ(), oneOverDet * t2.getX(), oneOverDet * t2.getY(), oneOverDet * t2.getZ()); } }
Matrix33 { public Matrix33 inverse() { double det = this.determinant(); if ( det == 0.0 ) throw new RuntimeException("This matrix is not invertable"); Vector3 v0 = new Vector3(m[0][0], m[1][0], m[2][0]); Vector3 v1 = new Vector3(m[0][1], m[1][1], m[2][1]); Vector3 v2 = new Vector3(m[0][2], m[1][2], m[2][2]); Vector3 t0 = v1.cross(v2); Vector3 t1 = v2.cross(v0); Vector3 t2 = v0.cross(v1); double oneOverDet = 1.0 / det; return new Matrix33 ( oneOverDet * t0.getX(), oneOverDet * t0.getY(), oneOverDet * t0.getZ(), oneOverDet * t1.getX(), oneOverDet * t1.getY(), oneOverDet * t1.getZ(), oneOverDet * t2.getX(), oneOverDet * t2.getY(), oneOverDet * t2.getZ()); } Matrix33();  Matrix33(double m00, double m01, double m02, 
	                double m10, double m11, double m12,
	                double m20, double m21, double m22); }
Matrix33 { public Matrix33 inverse() { double det = this.determinant(); if ( det == 0.0 ) throw new RuntimeException("This matrix is not invertable"); Vector3 v0 = new Vector3(m[0][0], m[1][0], m[2][0]); Vector3 v1 = new Vector3(m[0][1], m[1][1], m[2][1]); Vector3 v2 = new Vector3(m[0][2], m[1][2], m[2][2]); Vector3 t0 = v1.cross(v2); Vector3 t1 = v2.cross(v0); Vector3 t2 = v0.cross(v1); double oneOverDet = 1.0 / det; return new Matrix33 ( oneOverDet * t0.getX(), oneOverDet * t0.getY(), oneOverDet * t0.getZ(), oneOverDet * t1.getX(), oneOverDet * t1.getY(), oneOverDet * t1.getZ(), oneOverDet * t2.getX(), oneOverDet * t2.getY(), oneOverDet * t2.getZ()); } Matrix33();  Matrix33(double m00, double m01, double m02, 
	                double m10, double m11, double m12,
	                double m20, double m21, double m22); static Matrix33 makeTranslate(double x, double y); static Matrix33 makeScale(double sx, double sy ); void set(double m00, double m01, double m02, 
			        double m10, double m11, double m12,
			        double m20, double m21, double m22 ); Vector2 transform(Vector2 vector); Box2D transform(Box2D box); Matrix33 multiply(Matrix33 rhs); double determinant(); Matrix33 inverse(); void set(int row, int col,double value); double get(int row, int col); void setTranslationX(double value); void setTranslationY(double value); double getTranslationX(); double getTranslationY(); double getScaleX(); double getScaleY(); double getShearX(); double getShearY(); String toString(); }
Matrix33 { public Matrix33 inverse() { double det = this.determinant(); if ( det == 0.0 ) throw new RuntimeException("This matrix is not invertable"); Vector3 v0 = new Vector3(m[0][0], m[1][0], m[2][0]); Vector3 v1 = new Vector3(m[0][1], m[1][1], m[2][1]); Vector3 v2 = new Vector3(m[0][2], m[1][2], m[2][2]); Vector3 t0 = v1.cross(v2); Vector3 t1 = v2.cross(v0); Vector3 t2 = v0.cross(v1); double oneOverDet = 1.0 / det; return new Matrix33 ( oneOverDet * t0.getX(), oneOverDet * t0.getY(), oneOverDet * t0.getZ(), oneOverDet * t1.getX(), oneOverDet * t1.getY(), oneOverDet * t1.getZ(), oneOverDet * t2.getX(), oneOverDet * t2.getY(), oneOverDet * t2.getZ()); } Matrix33();  Matrix33(double m00, double m01, double m02, 
	                double m10, double m11, double m12,
	                double m20, double m21, double m22); static Matrix33 makeTranslate(double x, double y); static Matrix33 makeScale(double sx, double sy ); void set(double m00, double m01, double m02, 
			        double m10, double m11, double m12,
			        double m20, double m21, double m22 ); Vector2 transform(Vector2 vector); Box2D transform(Box2D box); Matrix33 multiply(Matrix33 rhs); double determinant(); Matrix33 inverse(); void set(int row, int col,double value); double get(int row, int col); void setTranslationX(double value); void setTranslationY(double value); double getTranslationX(); double getTranslationY(); double getScaleX(); double getScaleY(); double getShearX(); double getShearY(); String toString();  }