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 float myconst = (float) (Math.PI / 180);
35 public MCMatrix(int rows, int cols)
37 matrix = new float[rows][cols];
38 tmp = new float[rows][cols];
41 public void addElement(int i, int j, float value)
46 public void rotatex(float degrees)
48 mycos = (float) (Math.cos(degrees * myconst));
49 mysin = (float) (Math.sin(degrees * myconst));
63 public void rotatez(float degrees)
65 mycos = (float) (Math.cos(degrees * myconst));
66 mysin = (float) (Math.sin(degrees * myconst));
81 public void rotatey(float degrees)
83 mycos = (float) (Math.cos(degrees * myconst));
84 mysin = (float) (Math.sin(degrees * myconst));
99 public float[] vectorMultiply(float[] vect)
101 float[] temp = new float[3];
107 for (int i = 0; i < 3; i++)
109 temp[i] = ((float) matrix[i][0] * vect[0])
110 + ((float) matrix[i][1] * vect[1])
111 + ((float) matrix[i][2] * vect[2]);
121 public void preMultiply(float[][] mat)
123 float[][] tmp = new float[3][3];
125 for (int i = 0; i < 3; i++)
127 for (int j = 0; j < 3; j++)
129 tmp[i][j] = (mat[i][0] * matrix[0][j]) + (mat[i][1] * matrix[1][j])
130 + (mat[i][2] * matrix[2][j]);
134 for (int i = 0; i < 3; i++)
136 for (int j = 0; j < 3; j++)
138 matrix[i][j] = tmp[i][j];
143 public void postMultiply(float[][] mat)
145 float[][] tmp = new float[3][3];
147 for (int i = 0; i < 3; i++)
149 for (int j = 0; j < 3; j++)
151 tmp[i][j] = (matrix[i][0] * mat[0][j]) + (matrix[i][1] * mat[1][j])
152 + (matrix[i][2] * mat[2][j]);
156 for (int i = 0; i < 3; i++)
158 for (int j = 0; j < 3; j++)
160 matrix[i][j] = tmp[i][j];
165 public void setIdentity()