public class MCMatrix
{
- float[][] matrix;
+ double[][] matrix;
- float[][] tmp;
+ double[][] tmp;
- float mycos;
+ double mycos;
- float mysin;
+ double mysin;
- float myconst = (float) (Math.PI / 180);
+ double myconst = Math.PI / 180;
public MCMatrix(int rows, int cols)
{
- matrix = new float[rows][cols];
- tmp = new float[rows][cols];
+ matrix = new double[rows][cols];
+ tmp = new double[rows][cols];
}
- public void addElement(int i, int j, float value)
+ public void addElement(int i, int j, double value)
{
matrix[i][j] = value;
}
- public void rotatex(float degrees)
+ public void rotatex(double degrees)
{
- mycos = (float) (Math.cos(degrees * myconst));
- mysin = (float) (Math.sin(degrees * myconst));
+ mycos = (Math.cos(degrees * myconst));
+ mysin = (Math.sin(degrees * myconst));
tmp[0][0] = 1;
tmp[0][1] = 0;
preMultiply(tmp);
}
- public void rotatez(float degrees)
+ public void rotatez(double degrees)
{
- mycos = (float) (Math.cos(degrees * myconst));
- mysin = (float) (Math.sin(degrees * myconst));
+ mycos = (Math.cos(degrees * myconst));
+ mysin = (Math.sin(degrees * myconst));
tmp[0][0] = mycos;
tmp[0][1] = -mysin;
preMultiply(tmp);
}
- public void rotatey(float degrees)
+ public void rotatey(double degrees)
{
- mycos = (float) (Math.cos(degrees * myconst));
- mysin = (float) (Math.sin(degrees * myconst));
+ mycos = (Math.cos(degrees * myconst));
+ mysin = (Math.sin(degrees * myconst));
tmp[0][0] = mycos;
tmp[0][1] = 0;
preMultiply(tmp);
}
- public float[] vectorMultiply(float[] vect)
+ public double[] vectorMultiply(double[] vect)
{
- float[] temp = new float[3];
+ double[] temp = new double[3];
temp[0] = vect[0];
temp[1] = vect[1];
for (int i = 0; i < 3; i++)
{
- temp[i] = ((float) matrix[i][0] * vect[0])
- + ((float) matrix[i][1] * vect[1])
- + ((float) matrix[i][2] * vect[2]);
+ temp[i] = (matrix[i][0] * vect[0]) + (matrix[i][1] * vect[1])
+ + (matrix[i][2] * vect[2]);
}
vect[0] = temp[0];
return vect;
}
- public void preMultiply(float[][] mat)
+ public void preMultiply(double[][] mat)
{
- float[][] tmp = new float[3][3];
+ double[][] tmp = new double[3][3];
for (int i = 0; i < 3; i++)
{
}
}
- public void postMultiply(float[][] mat)
+ public void postMultiply(double[][] mat)
{
- float[][] tmp = new float[3][3];
+ double[][] tmp = new double[3][3];
for (int i = 0; i < 3; i++)
{