/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
-*/\r
-\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package MCview;\r
\r
-public class MCMatrix {\r
- float matrix[][];\r
- float tmp[][];\r
-\r
+public class MCMatrix\r
+{\r
+ float[][] matrix;\r
+ float[][] tmp;\r
float mycos;\r
float mysin;\r
- float myconst = (float)(Math.PI/180);\r
+ float myconst = (float) (Math.PI / 180);\r
\r
- public MCMatrix(int rows, int cols) {\r
+ public MCMatrix(int rows, int cols)\r
+ {\r
matrix = new float[rows][cols];\r
- tmp = new float[rows][cols];\r
+ tmp = new float[rows][cols];\r
}\r
\r
- public void addElement(int i, int j, float value) {\r
+ public void addElement(int i, int j, float value)\r
+ {\r
matrix[i][j] = value;\r
}\r
\r
- public void print() {\r
- System.out.println(matrix[0][0] + " " + matrix[0][1] + " " + matrix[0][2]);\r
- System.out.println(matrix[1][0] + " " + matrix[1][1] + " " + matrix[1][2]);\r
- System.out.println(matrix[2][0] + " " + matrix[2][1] + " " + matrix[2][2]);\r
- }\r
-\r
- public void rotatex(float degrees) {\r
- mycos = (float)(Math.cos(degrees*myconst));\r
- mysin = (float)(Math.sin(degrees*myconst));\r
+ public void rotatex(float degrees)\r
+ {\r
+ mycos = (float) (Math.cos(degrees * myconst));\r
+ mysin = (float) (Math.sin(degrees * myconst));\r
\r
tmp[0][0] = 1;\r
tmp[0][1] = 0;\r
preMultiply(tmp);\r
}\r
\r
- public void rotatez(float degrees) {\r
- mycos = (float)(Math.cos(degrees*myconst));\r
- mysin = (float)(Math.sin(degrees*myconst));\r
+ public void rotatez(float degrees)\r
+ {\r
+ mycos = (float) (Math.cos(degrees * myconst));\r
+ mysin = (float) (Math.sin(degrees * myconst));\r
\r
tmp[0][0] = mycos;\r
tmp[0][1] = -mysin;\r
preMultiply(tmp);\r
}\r
\r
- public void rotatey(float degrees) {\r
- mycos = (float)(Math.cos(degrees*myconst));\r
- mysin = (float)(Math.sin(degrees*myconst));\r
+ public void rotatey(float degrees)\r
+ {\r
+ mycos = (float) (Math.cos(degrees * myconst));\r
+ mysin = (float) (Math.sin(degrees * myconst));\r
\r
tmp[0][0] = mycos;\r
tmp[0][1] = 0;\r
preMultiply(tmp);\r
}\r
\r
- public float[] vectorMultiply(float[] vect) {\r
- float temp[] = new float[3];\r
+ public float[] vectorMultiply(float[] vect)\r
+ {\r
+ float[] temp = new float[3];\r
\r
temp[0] = vect[0];\r
temp[1] = vect[1];\r
temp[2] = vect[2];\r
\r
- for (int i = 0; i < 3; i++) {\r
- temp[i] = (float)matrix[i][0]*vect[0] + (float)matrix[i][1]*vect[1] +(float)matrix[i][2]*vect[2];\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ temp[i] = ( (float) matrix[i][0] * vect[0]) +\r
+ ( (float) matrix[i][1] * vect[1]) +\r
+ ( (float) matrix[i][2] * vect[2]);\r
}\r
\r
vect[0] = temp[0];\r
return vect;\r
}\r
\r
- public void preMultiply(float mat[][]) {\r
- float tmp[][] = new float[3][3];\r
+ public void preMultiply(float[][] mat)\r
+ {\r
+ float[][] tmp = new float[3][3];\r
\r
- for (int i = 0; i < 3 ; i++) {\r
- for (int j = 0; j < 3; j++ ) {\r
- tmp[i][j] = mat[i][0]*matrix[0][j] +\r
- mat[i][1]*matrix[1][j] +\r
- mat[i][2]*matrix[2][j];\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ for (int j = 0; j < 3; j++)\r
+ {\r
+ tmp[i][j] = (mat[i][0] * matrix[0][j]) +\r
+ (mat[i][1] * matrix[1][j]) + (mat[i][2] * matrix[2][j]);\r
}\r
}\r
\r
- for (int i = 0; i < 3 ; i++) {\r
- for (int j = 0; j < 3; j++ ) {\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ for (int j = 0; j < 3; j++)\r
+ {\r
matrix[i][j] = tmp[i][j];\r
}\r
}\r
}\r
\r
- public void postMultiply(float mat[][]) {\r
- float tmp[][] = new float[3][3];\r
+ public void postMultiply(float[][] mat)\r
+ {\r
+ float[][] tmp = new float[3][3];\r
\r
- for (int i = 0; i < 3 ; i++) {\r
- for (int j = 0; j < 3; j++ ) {\r
- tmp[i][j] = matrix[i][0]*mat[0][j] +\r
- matrix[i][1]*mat[1][j] +\r
- matrix[i][2]*mat[2][j];\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ for (int j = 0; j < 3; j++)\r
+ {\r
+ tmp[i][j] = (matrix[i][0] * mat[0][j]) +\r
+ (matrix[i][1] * mat[1][j]) + (matrix[i][2] * mat[2][j]);\r
}\r
}\r
\r
- for (int i = 0; i < 3 ; i++) {\r
- for (int j = 0; j < 3; j++ ) {\r
+ for (int i = 0; i < 3; i++)\r
+ {\r
+ for (int j = 0; j < 3; j++)\r
+ {\r
matrix[i][j] = tmp[i][j];\r
}\r
}\r
}\r
\r
- public void setIdentity() {\r
+ public void setIdentity()\r
+ {\r
matrix[0][0] = 1;\r
matrix[1][1] = 1;\r
matrix[2][2] = 1;\r
matrix[2][1] = 0;\r
}\r
}\r
-\r
-\r