2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
33 double myconst = Math.PI / 180;
35 public MCMatrix(int rows, int cols)
37 matrix = new double[rows][cols];
38 tmp = new double[rows][cols];
41 public void addElement(int i, int j, double value)
46 public void rotatex(double degrees)
48 mycos = (Math.cos(degrees * myconst));
49 mysin = (Math.sin(degrees * myconst));
63 public void rotatez(double degrees)
65 mycos = (Math.cos(degrees * myconst));
66 mysin = (Math.sin(degrees * myconst));
81 public void rotatey(double degrees)
83 mycos = (Math.cos(degrees * myconst));
84 mysin = (Math.sin(degrees * myconst));
99 public double[] vectorMultiply(double[] vect)
101 double[] temp = new double[3];
107 for (int i = 0; i < 3; i++)
109 temp[i] = (matrix[i][0] * vect[0]) + (matrix[i][1] * vect[1])
110 + (matrix[i][2] * vect[2]);
120 public void preMultiply(double[][] mat)
122 double[][] tmp = new double[3][3];
124 for (int i = 0; i < 3; i++)
126 for (int j = 0; j < 3; j++)
128 tmp[i][j] = (mat[i][0] * matrix[0][j]) + (mat[i][1] * matrix[1][j])
129 + (mat[i][2] * matrix[2][j]);
133 for (int i = 0; i < 3; i++)
135 for (int j = 0; j < 3; j++)
137 matrix[i][j] = tmp[i][j];
142 public void postMultiply(double[][] mat)
144 double[][] tmp = new double[3][3];
146 for (int i = 0; i < 3; i++)
148 for (int j = 0; j < 3; j++)
150 tmp[i][j] = (matrix[i][0] * mat[0][j]) + (matrix[i][1] * mat[1][j])
151 + (matrix[i][2] * mat[2][j]);
155 for (int i = 0; i < 3; i++)
157 for (int j = 0; j < 3; j++)
159 matrix[i][j] = tmp[i][j];
164 public void setIdentity()