1 package edu.ucla.iBeaconNav;
4 public float[] mValue = new float[9];
7 for (int i=0; i<9; i++){
12 public Matrix(float[] m){
13 for (int i=0; i<9; i++){
18 public Matrix rotateX(float thetaX){
19 float[] rtX = {1, 0, 0,
20 0, (float)Math.cos(thetaX),(float)-Math.sin(thetaX),
21 0, (float)Math.sin(thetaX),(float) Math.cos(thetaX)};
22 return new Matrix(rtX);
25 public Matrix rotateY(float thetaY){
26 float[] rtY = {(float) Math.cos(thetaY), 0, (float)Math.sin(thetaY),
28 (float)-Math.sin(thetaY), 0, (float)Math.cos(thetaY)};
29 return new Matrix(rtY);
32 public Matrix rotateZ(float thetaZ){
33 float[] rtZ = {(float)Math.cos(thetaZ),(float)-Math.sin(thetaZ), 0,
34 (float)Math.sin(thetaZ),(float) Math.cos(thetaZ), 0,
36 return new Matrix(rtZ);
39 public Matrix multiple(Matrix m){
40 float[] result = new float[9];
41 for (int k1=0; k1<9; k1++){
45 for (int k2=0; k2<3; k2++){
46 result[k1]+=mValue[i*3+k2]*m.mValue[k2*3+j];
50 return new Matrix(result);
53 public float[] multipleV(float[] v){
54 float[] result = new float[3];
55 for(int i=0; i<3; i++){
57 for(int j=0; j<3; j++){
58 result[i]+=mValue[3*i+j]*v[j];
64 public Matrix transpose(){
65 float[] result = new float[9];
66 result[0] = mValue[0];
67 result[1] = mValue[3];
68 result[2] = mValue[6];
69 result[4] = mValue[4];
70 result[3] = mValue[1];
71 result[5] = mValue[7];
72 result[6] = mValue[2];
73 result[7] = mValue[5];
74 result[8] = mValue[8];
75 return new Matrix(result);