Matrix3 { public Matrix3 setToMultiply(Matrix3 a, Matrix3 b) { if (a == null || b == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Matrix3", "setToMultiply", "missingMatrix")); } double[] ma = a.m; double[] mb = b.m; this.m[0] = (ma[0] * mb[0]) + (ma[1] * mb[3]) + (ma[2] * mb[6]); this.m[1] = (ma[0] * mb[1]) + (ma[1] * mb[4]) + (ma[2] * mb[7]); this.m[2] = (ma[0] * mb[2]) + (ma[1] * mb[5]) + (ma[2] * mb[8]); this.m[3] = (ma[3] * mb[0]) + (ma[4] * mb[3]) + (ma[5] * mb[6]); this.m[4] = (ma[3] * mb[1]) + (ma[4] * mb[4]) + (ma[5] * mb[7]); this.m[5] = (ma[3] * mb[2]) + (ma[4] * mb[5]) + (ma[5] * mb[8]); this.m[6] = (ma[6] * mb[0]) + (ma[7] * mb[3]) + (ma[8] * mb[6]); this.m[7] = (ma[6] * mb[1]) + (ma[7] * mb[4]) + (ma[8] * mb[7]); this.m[8] = (ma[6] * mb[2]) + (ma[7] * mb[5]) + (ma[8] * mb[8]); return this; } Matrix3();  Matrix3(double m11, double m12, double m13,
                   double m21, double m22, double m23,
                   double m31, double m32, double m33);  Matrix3(Matrix3 matrix); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Matrix3 set(double m11, double m12, double m13,
                       double m21, double m22, double m23,
                       double m31, double m32, double m33); Matrix3 set(Matrix3 matrix); Matrix3 setTranslation(double x, double y); Matrix3 setRotation(double angleDegrees); Matrix3 setScale(double xScale, double yScale); Matrix3 setToIdentity(); Matrix3 setToTranslation(double x, double y); Matrix3 setToRotation(double angleDegrees); Matrix3 setToScale(double xScale, double yScale); Matrix3 setToVerticalFlip(); Matrix3 setToTileTransform(Sector src, Sector dst); Matrix3 setToMultiply(Matrix3 a, Matrix3 b); Matrix3 multiplyByTranslation(double x, double y); Matrix3 multiplyByRotation(double angleDegrees); Matrix3 multiplyByScale(double xScale, double yScale); Matrix3 multiplyByVerticalFlip(); Matrix3 multiplyByTileTransform(Sector src, Sector dst); Matrix3 multiplyByMatrix(Matrix3 matrix); Matrix3 multiplyByMatrix(double m11, double m12, double m13,
                                    double m21, double m22, double m23,
                                    double m31, double m32, double m33); Matrix3 transpose(); Matrix3 transposeMatrix(Matrix3 matrix); float[] transposeToArray(float[] result, int offset); Matrix3 invert(); Matrix3 invertMatrix(Matrix3 matrix); final double[] m; }
@Test public void testSetToMultiply() throws Exception { Matrix3 m1 = new Matrix3(); Matrix3 a = new Matrix3( 11d, 12d, 13d, 21d, 22d, 23d, 31d, 32d, 33d); Matrix3 b = new Matrix3( 11d, 12d, 13d, 21d, 22d, 23d, 31d, 32d, 33d); Matrix3 m2 = m1.setToMultiply(a, b); assertEquals("m11", (a.m[0] * b.m[0]) + (a.m[1] * b.m[3]) + (a.m[2] * b.m[6]), m1.m[0], 0); assertEquals("m21", (a.m[3] * b.m[0]) + (a.m[4] * b.m[3]) + (a.m[5] * b.m[6]), m1.m[3], 0); assertEquals("m31", (a.m[6] * b.m[0]) + (a.m[7] * b.m[3]) + (a.m[8] * b.m[6]), m1.m[6], 0); assertEquals("m12", (a.m[0] * b.m[1]) + (a.m[1] * b.m[4]) + (a.m[2] * b.m[7]), m1.m[1], 0); assertEquals("m22", (a.m[3] * b.m[1]) + (a.m[4] * b.m[4]) + (a.m[5] * b.m[7]), m1.m[4], 0); assertEquals("m23", (a.m[6] * b.m[1]) + (a.m[7] * b.m[4]) + (a.m[8] * b.m[7]), m1.m[7], 0); assertEquals("m13", (a.m[0] * b.m[2]) + (a.m[1] * b.m[5]) + (a.m[2] * b.m[8]), m1.m[2], 0); assertEquals("m32", (a.m[3] * b.m[2]) + (a.m[4] * b.m[5]) + (a.m[5] * b.m[8]), m1.m[5], 0); assertEquals("m33", (a.m[6] * b.m[2]) + (a.m[7] * b.m[5]) + (a.m[8] * b.m[8]), m1.m[8], 0); assertSame("fluent api result", m2, m1); }