1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package mc_view; |
22 |
|
|
|
|
| 0% |
Uncovered Elements: 99 (99) |
Complexity: 18 |
Complexity Density: 0.25 |
|
23 |
|
public class MCMatrix |
24 |
|
{ |
25 |
|
float[][] matrix; |
26 |
|
|
27 |
|
float[][] tmp; |
28 |
|
|
29 |
|
float mycos; |
30 |
|
|
31 |
|
float mysin; |
32 |
|
|
33 |
|
float myconst = (float) (Math.PI / 180); |
34 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
35 |
0 |
public MCMatrix(int rows, int cols)... |
36 |
|
{ |
37 |
0 |
matrix = new float[rows][cols]; |
38 |
0 |
tmp = new float[rows][cols]; |
39 |
|
} |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
41 |
0 |
public void addElement(int i, int j, float value)... |
42 |
|
{ |
43 |
0 |
matrix[i][j] = value; |
44 |
|
} |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
46 |
0 |
public void rotatex(float degrees)... |
47 |
|
{ |
48 |
0 |
mycos = (float) (Math.cos(degrees * myconst)); |
49 |
0 |
mysin = (float) (Math.sin(degrees * myconst)); |
50 |
|
|
51 |
0 |
tmp[0][0] = 1; |
52 |
0 |
tmp[0][1] = 0; |
53 |
0 |
tmp[0][2] = 0; |
54 |
0 |
tmp[1][0] = 0; |
55 |
0 |
tmp[1][1] = mycos; |
56 |
0 |
tmp[1][2] = mysin; |
57 |
0 |
tmp[2][0] = 0; |
58 |
0 |
tmp[2][1] = -mysin; |
59 |
0 |
tmp[2][2] = mycos; |
60 |
0 |
preMultiply(tmp); |
61 |
|
} |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
63 |
0 |
public void rotatez(float degrees)... |
64 |
|
{ |
65 |
0 |
mycos = (float) (Math.cos(degrees * myconst)); |
66 |
0 |
mysin = (float) (Math.sin(degrees * myconst)); |
67 |
|
|
68 |
0 |
tmp[0][0] = mycos; |
69 |
0 |
tmp[0][1] = -mysin; |
70 |
0 |
tmp[0][2] = 0; |
71 |
0 |
tmp[1][0] = mysin; |
72 |
0 |
tmp[1][1] = mycos; |
73 |
0 |
tmp[1][2] = 0; |
74 |
0 |
tmp[2][0] = 0; |
75 |
0 |
tmp[2][1] = 0; |
76 |
0 |
tmp[2][2] = 1; |
77 |
|
|
78 |
0 |
preMultiply(tmp); |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
81 |
0 |
public void rotatey(float degrees)... |
82 |
|
{ |
83 |
0 |
mycos = (float) (Math.cos(degrees * myconst)); |
84 |
0 |
mysin = (float) (Math.sin(degrees * myconst)); |
85 |
|
|
86 |
0 |
tmp[0][0] = mycos; |
87 |
0 |
tmp[0][1] = 0; |
88 |
0 |
tmp[0][2] = -mysin; |
89 |
0 |
tmp[1][0] = 0; |
90 |
0 |
tmp[1][1] = 1; |
91 |
0 |
tmp[1][2] = 0; |
92 |
0 |
tmp[2][0] = mysin; |
93 |
0 |
tmp[2][1] = 0; |
94 |
0 |
tmp[2][2] = mycos; |
95 |
|
|
96 |
0 |
preMultiply(tmp); |
97 |
|
} |
98 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
99 |
0 |
public float[] vectorMultiply(float[] vect)... |
100 |
|
{ |
101 |
0 |
float[] temp = new float[3]; |
102 |
|
|
103 |
0 |
temp[0] = vect[0]; |
104 |
0 |
temp[1] = vect[1]; |
105 |
0 |
temp[2] = vect[2]; |
106 |
|
|
107 |
0 |
for (int i = 0; i < 3; i++) |
108 |
|
{ |
109 |
0 |
temp[i] = ((float) matrix[i][0] * vect[0]) |
110 |
|
+ ((float) matrix[i][1] * vect[1]) |
111 |
|
+ ((float) matrix[i][2] * vect[2]); |
112 |
|
} |
113 |
|
|
114 |
0 |
vect[0] = temp[0]; |
115 |
0 |
vect[1] = temp[1]; |
116 |
0 |
vect[2] = temp[2]; |
117 |
|
|
118 |
0 |
return vect; |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.71 |
|
121 |
0 |
public void preMultiply(float[][] mat)... |
122 |
|
{ |
123 |
0 |
float[][] tmp = new float[3][3]; |
124 |
|
|
125 |
0 |
for (int i = 0; i < 3; i++) |
126 |
|
{ |
127 |
0 |
for (int j = 0; j < 3; j++) |
128 |
|
{ |
129 |
0 |
tmp[i][j] = (mat[i][0] * matrix[0][j]) + (mat[i][1] * matrix[1][j]) |
130 |
|
+ (mat[i][2] * matrix[2][j]); |
131 |
|
} |
132 |
|
} |
133 |
|
|
134 |
0 |
for (int i = 0; i < 3; i++) |
135 |
|
{ |
136 |
0 |
for (int j = 0; j < 3; j++) |
137 |
|
{ |
138 |
0 |
matrix[i][j] = tmp[i][j]; |
139 |
|
} |
140 |
|
} |
141 |
|
} |
142 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.71 |
|
143 |
0 |
public void postMultiply(float[][] mat)... |
144 |
|
{ |
145 |
0 |
float[][] tmp = new float[3][3]; |
146 |
|
|
147 |
0 |
for (int i = 0; i < 3; i++) |
148 |
|
{ |
149 |
0 |
for (int j = 0; j < 3; j++) |
150 |
|
{ |
151 |
0 |
tmp[i][j] = (matrix[i][0] * mat[0][j]) + (matrix[i][1] * mat[1][j]) |
152 |
|
+ (matrix[i][2] * mat[2][j]); |
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
0 |
for (int i = 0; i < 3; i++) |
157 |
|
{ |
158 |
0 |
for (int j = 0; j < 3; j++) |
159 |
|
{ |
160 |
0 |
matrix[i][j] = tmp[i][j]; |
161 |
|
} |
162 |
|
} |
163 |
|
} |
164 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
165 |
0 |
public void setIdentity()... |
166 |
|
{ |
167 |
0 |
matrix[0][0] = 1; |
168 |
0 |
matrix[1][1] = 1; |
169 |
0 |
matrix[2][2] = 1; |
170 |
0 |
matrix[0][1] = 0; |
171 |
0 |
matrix[0][2] = 0; |
172 |
0 |
matrix[1][0] = 0; |
173 |
0 |
matrix[1][2] = 0; |
174 |
0 |
matrix[2][0] = 0; |
175 |
0 |
matrix[2][1] = 0; |
176 |
|
} |
177 |
|
} |