Here you can find the source of multiplyMatrixes(double[][] m1, double[][] m2)
Parameter | Description |
---|---|
m1 | a matrix (double[3][3]) |
m2 | a matrix (double[3][3]) |
public static double[][] multiplyMatrixes(double[][] m1, double[][] m2)
//package com.java2s; /*// w ww .j a v a2s .c o m * Scaffold Hunter * Copyright (C) 2006-2008 PG504 * Copyright (C) 2010-2011 PG552 * See README.txt in the root directory of the Scaffold Hunter source tree * for details. * * Scaffold Hunter is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Scaffold Hunter is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * multiplies matrixes * * result = m1*m2 * * @param m1 * a matrix (double[3][3]) * @param m2 * a matrix (double[3][3]) * @return * a matrix (double[3][3]) */ public static double[][] multiplyMatrixes(double[][] m1, double[][] m2) { double[][] result = new double[3][3]; multiplyMatrixes(m1, m2, result); return result; } /** * multiplies matrixes * * result = m1*m2 * * @param m1 * a matrix (double[3][3]) * @param m2 * a matrix (double[3][3]) * @param result * a matrix (double[3][3]) */ public static void multiplyMatrixes(double[][] m1, double[][] m2, double[][] result) { result[0][0] = m1[0][0] * m2[0][0] + m1[0][1] * m2[1][0] + m1[0][2] * m2[2][0]; result[0][1] = m1[0][0] * m2[0][1] + m1[0][1] * m2[1][1] + m1[0][2] * m2[2][1]; result[0][2] = m1[0][0] * m2[0][2] + m1[0][1] * m2[1][2] + m1[0][2] * m2[2][2]; result[1][0] = m1[1][0] * m2[0][0] + m1[1][1] * m2[1][0] + m1[1][2] * m2[2][0]; result[1][1] = m1[1][0] * m2[0][1] + m1[1][1] * m2[1][1] + m1[1][2] * m2[2][1]; result[1][2] = m1[1][0] * m2[0][2] + m1[1][1] * m2[1][2] + m1[1][2] * m2[2][2]; result[2][0] = m1[2][0] * m2[0][0] + m1[2][1] * m2[1][0] + +m1[2][2] * m2[2][0]; result[2][1] = m1[2][0] * m2[0][1] + m1[2][1] * m2[1][1] + +m1[2][2] * m2[2][1]; result[2][2] = m1[2][0] * m2[0][2] + m1[2][1] * m2[1][2] + +m1[2][2] * m2[2][2]; } }