Matrix3 { public Matrix3 multiplyByMatrix(Matrix3 matrix) { if (matrix == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Matrix3", "multiplyByMatrix", "missingMatrix")); } double[] ma = this.m; double[] mb = matrix.m; double ma0, ma1, ma2; ma0 = ma[0]; ma1 = ma[1]; ma2 = ma[2]; ma[0] = (ma0 * mb[0]) + (ma1 * mb[3]) + (ma2 * mb[6]); ma[1] = (ma0 * mb[1]) + (ma1 * mb[4]) + (ma2 * mb[7]); ma[2] = (ma0 * mb[2]) + (ma1 * mb[5]) + (ma2 * mb[8]); ma0 = ma[3]; ma1 = ma[4]; ma2 = ma[5]; ma[3] = (ma0 * mb[0]) + (ma1 * mb[3]) + (ma2 * mb[6]); ma[4] = (ma0 * mb[1]) + (ma1 * mb[4]) + (ma2 * mb[7]); ma[5] = (ma0 * mb[2]) + (ma1 * mb[5]) + (ma2 * mb[8]); ma0 = ma[6]; ma1 = ma[7]; ma2 = ma[8]; ma[6] = (ma0 * mb[0]) + (ma1 * mb[3]) + (ma2 * mb[6]); ma[7] = (ma0 * mb[1]) + (ma1 * mb[4]) + (ma2 * mb[7]); ma[8] = (ma0 * mb[2]) + (ma1 * mb[5]) + (ma2 * 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 testMultiplyByMatrix() throws Exception { Matrix3 m1 = new Matrix3( 11d, 12d, 13d, 21d, 22d, 23d, 31d, 32d, 33d); Matrix3 m2 = new Matrix3( 11d, 12d, 13d, 21d, 22d, 23d, 31d, 32d, 33d); Matrix3 copy = new Matrix3(); copy.set(m1); Matrix3 m3 = m1.multiplyByMatrix(m2); assertEquals("m11", (copy.m[0] * m2.m[0]) + (copy.m[1] * m2.m[3]) + (copy.m[2] * m2.m[6]), m1.m[0], 0); assertEquals("m21", (copy.m[3] * m2.m[0]) + (copy.m[4] * m2.m[3]) + (copy.m[5] * m2.m[6]), m1.m[3], 0); assertEquals("m31", (copy.m[6] * m2.m[0]) + (copy.m[7] * m2.m[3]) + (copy.m[8] * m2.m[6]), m1.m[6], 0); assertEquals("m12", (copy.m[0] * m2.m[1]) + (copy.m[1] * m2.m[4]) + (copy.m[2] * m2.m[7]), m1.m[1], 0); assertEquals("m22", (copy.m[3] * m2.m[1]) + (copy.m[4] * m2.m[4]) + (copy.m[5] * m2.m[7]), m1.m[4], 0); assertEquals("m23", (copy.m[6] * m2.m[1]) + (copy.m[7] * m2.m[4]) + (copy.m[8] * m2.m[7]), m1.m[7], 0); assertEquals("m13", (copy.m[0] * m2.m[2]) + (copy.m[1] * m2.m[5]) + (copy.m[2] * m2.m[8]), m1.m[2], 0); assertEquals("m32", (copy.m[3] * m2.m[2]) + (copy.m[4] * m2.m[5]) + (copy.m[5] * m2.m[8]), m1.m[5], 0); assertEquals("m33", (copy.m[6] * m2.m[2]) + (copy.m[7] * m2.m[5]) + (copy.m[8] * m2.m[8]), m1.m[8], 0); assertSame("fluent api result", m3, m1); }