Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | static const float inv_dist_to_plane = 1.0f / 1024.0f; | - |
5 | QMatrix4x4::QMatrix4x4(const float *values) | - |
6 | { | - |
7 | for (int row = 0; row < 4; ++row) evaluated: row < 4 yes Evaluation Count:476 | yes Evaluation Count:119 |
| 119-476 |
8 | for (int col = 0; col < 4; ++col) evaluated: col < 4 yes Evaluation Count:1904 | yes Evaluation Count:476 |
| 476-1904 |
9 | m[col][row] = values[row * 4 + col]; executed: m[col][row] = values[row * 4 + col]; Execution Count:1904 | 1904 |
10 | flagBits = General; | - |
11 | } executed: } Execution Count:119 | 119 |
12 | QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows) | - |
13 | { | - |
14 | for (int col = 0; col < 4; ++col) { evaluated: col < 4 yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
15 | for (int row = 0; row < 4; ++row) { evaluated: row < 4 yes Evaluation Count:16 | yes Evaluation Count:4 |
| 4-16 |
16 | if (col < cols && row < rows) partially evaluated: col < cols yes Evaluation Count:16 | no Evaluation Count:0 |
evaluated: row < rows yes Evaluation Count:12 | yes Evaluation Count:4 |
| 0-16 |
17 | m[col][row] = values[col * rows + row]; executed: m[col][row] = values[col * rows + row]; Execution Count:12 | 12 |
18 | else if (col == row) evaluated: col == row yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
19 | m[col][row] = 1.0f; executed: m[col][row] = 1.0f; Execution Count:1 | 1 |
20 | else | - |
21 | m[col][row] = 0.0f; executed: m[col][row] = 0.0f; Execution Count:3 | 3 |
22 | } | - |
23 | } executed: } Execution Count:4 | 4 |
24 | flagBits = General; | - |
25 | } executed: } Execution Count:1 | 1 |
26 | QMatrix4x4::QMatrix4x4(const QMatrix& matrix) | - |
27 | { | - |
28 | m[0][0] = matrix.m11(); | - |
29 | m[0][1] = matrix.m12(); | - |
30 | m[0][2] = 0.0f; | - |
31 | m[0][3] = 0.0f; | - |
32 | m[1][0] = matrix.m21(); | - |
33 | m[1][1] = matrix.m22(); | - |
34 | m[1][2] = 0.0f; | - |
35 | m[1][3] = 0.0f; | - |
36 | m[2][0] = 0.0f; | - |
37 | m[2][1] = 0.0f; | - |
38 | m[2][2] = 1.0f; | - |
39 | m[2][3] = 0.0f; | - |
40 | m[3][0] = matrix.dx(); | - |
41 | m[3][1] = matrix.dy(); | - |
42 | m[3][2] = 0.0f; | - |
43 | m[3][3] = 1.0f; | - |
44 | flagBits = Translation | Scale | Rotation2D; | - |
45 | } executed: } Execution Count:3 | 3 |
46 | QMatrix4x4::QMatrix4x4(const QTransform& transform) | - |
47 | { | - |
48 | m[0][0] = transform.m11(); | - |
49 | m[0][1] = transform.m12(); | - |
50 | m[0][2] = 0.0f; | - |
51 | m[0][3] = transform.m13(); | - |
52 | m[1][0] = transform.m21(); | - |
53 | m[1][1] = transform.m22(); | - |
54 | m[1][2] = 0.0f; | - |
55 | m[1][3] = transform.m23(); | - |
56 | m[2][0] = 0.0f; | - |
57 | m[2][1] = 0.0f; | - |
58 | m[2][2] = 1.0f; | - |
59 | m[2][3] = 0.0f; | - |
60 | m[3][0] = transform.dx(); | - |
61 | m[3][1] = transform.dy(); | - |
62 | m[3][2] = 0.0f; | - |
63 | m[3][3] = transform.m33(); | - |
64 | flagBits = General; | - |
65 | } executed: } Execution Count:2891 | 2891 |
66 | static inline double matrixDet2(const double m[4][4], int col0, int col1, int row0, int row1) | - |
67 | { | - |
68 | return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0]; executed: return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0]; Execution Count:668 | 668 |
69 | } | - |
70 | static inline double matrixDet3 | - |
71 | (const double m[4][4], int col0, int col1, int col2, | - |
72 | int row0, int row1, int row2) | - |
73 | { | - |
74 | return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2) | 218 |
75 | - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2) | 218 |
76 | + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2); executed: return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2) - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2) + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2); Execution Count:218 | 218 |
77 | } | - |
78 | | - |
79 | | - |
80 | static inline double matrixDet4(const double m[4][4]) | - |
81 | { | - |
82 | double det; | - |
83 | det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3); | - |
84 | det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3); | - |
85 | det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3); | - |
86 | det -= m[3][0] * matrixDet3(m, 0, 1, 2, 1, 2, 3); | - |
87 | return det; executed: return det; Execution Count:23 | 23 |
88 | } | - |
89 | | - |
90 | static inline void copyToDoubles(const float m[4][4], double mm[4][4]) | - |
91 | { | - |
92 | for (int i = 0; i < 4; ++i) evaluated: i < 4 yes Evaluation Count:168 | yes Evaluation Count:42 |
| 42-168 |
93 | for (int j = 0; j < 4; ++j) evaluated: j < 4 yes Evaluation Count:672 | yes Evaluation Count:168 |
| 168-672 |
94 | mm[i][j] = double(m[i][j]); executed: mm[i][j] = double(m[i][j]); Execution Count:672 | 672 |
95 | } executed: } Execution Count:42 | 42 |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | double QMatrix4x4::determinant() const | - |
101 | { | - |
102 | if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity) partially evaluated: (flagBits & ~(Translation | Rotation2D | Rotation)) == Identity no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
103 | return 1.0; never executed: return 1.0; | 0 |
104 | | - |
105 | double mm[4][4]; | - |
106 | copyToDoubles(m, mm); | - |
107 | if (flagBits < Rotation2D) partially evaluated: flagBits < Rotation2D no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
108 | return mm[0][0] * mm[1][1] * mm[2][2]; never executed: return mm[0][0] * mm[1][1] * mm[2][2]; | 0 |
109 | if (flagBits < Perspective) partially evaluated: flagBits < Perspective no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
110 | return matrixDet3(mm, 0, 1, 2, 0, 1, 2); never executed: return matrixDet3(mm, 0, 1, 2, 0, 1, 2); | 0 |
111 | return matrixDet4(mm); executed: return matrixDet4(mm); Execution Count:12 | 12 |
112 | } | - |
113 | QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const | - |
114 | { | - |
115 | | - |
116 | if (flagBits == Identity) { evaluated: flagBits == Identity yes Evaluation Count:3 | yes Evaluation Count:16 |
| 3-16 |
117 | if (invertible) evaluated: invertible yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
118 | *invertible = true; executed: *invertible = true; Execution Count:1 | 1 |
119 | return QMatrix4x4(); executed: return QMatrix4x4(); Execution Count:3 | 3 |
120 | } else if (flagBits == Translation) { evaluated: flagBits == Translation yes Evaluation Count:1 | yes Evaluation Count:15 |
| 1-15 |
121 | QMatrix4x4 inv; | - |
122 | inv.m[3][0] = -m[3][0]; | - |
123 | inv.m[3][1] = -m[3][1]; | - |
124 | inv.m[3][2] = -m[3][2]; | - |
125 | inv.flagBits = Translation; | - |
126 | if (invertible) partially evaluated: invertible yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
127 | *invertible = true; executed: *invertible = true; Execution Count:1 | 1 |
128 | return inv; executed: return inv; Execution Count:1 | 1 |
129 | } else if (flagBits < Rotation2D) { evaluated: flagBits < Rotation2D yes Evaluation Count:1 | yes Evaluation Count:14 |
| 1-14 |
130 | | - |
131 | if (m[0][0] == 0 || m[1][1] == 0 || m[2][2] == 0) { partially evaluated: m[0][0] == 0 no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: m[1][1] == 0 no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: m[2][2] == 0 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
132 | if (invertible) never evaluated: invertible | 0 |
133 | *invertible = false; never executed: *invertible = false; | 0 |
134 | return QMatrix4x4(); never executed: return QMatrix4x4(); | 0 |
135 | } | - |
136 | QMatrix4x4 inv; | - |
137 | inv.m[0][0] = 1.0f / m[0][0]; | - |
138 | inv.m[1][1] = 1.0f / m[1][1]; | - |
139 | inv.m[2][2] = 1.0f / m[2][2]; | - |
140 | inv.m[3][0] = -m[3][0] * inv.m[0][0]; | - |
141 | inv.m[3][1] = -m[3][1] * inv.m[1][1]; | - |
142 | inv.m[3][2] = -m[3][2] * inv.m[2][2]; | - |
143 | inv.flagBits = flagBits; | - |
144 | | - |
145 | if (invertible) partially evaluated: invertible yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
146 | *invertible = true; executed: *invertible = true; Execution Count:1 | 1 |
147 | return inv; executed: return inv; Execution Count:1 | 1 |
148 | } else if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity) { evaluated: (flagBits & ~(Translation | Rotation2D | Rotation)) == Identity yes Evaluation Count:2 | yes Evaluation Count:12 |
| 2-12 |
149 | if (invertible) evaluated: invertible yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
150 | *invertible = true; executed: *invertible = true; Execution Count:1 | 1 |
151 | return orthonormalInverse(); executed: return orthonormalInverse(); Execution Count:2 | 2 |
152 | } else if (flagBits < Perspective) { evaluated: flagBits < Perspective yes Evaluation Count:1 | yes Evaluation Count:11 |
| 1-11 |
153 | QMatrix4x4 inv(1); | - |
154 | | - |
155 | double mm[4][4]; | - |
156 | copyToDoubles(m, mm); | - |
157 | | - |
158 | double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2); | - |
159 | if (det == 0.0f) { partially evaluated: det == 0.0f no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
160 | if (invertible) never evaluated: invertible | 0 |
161 | *invertible = false; never executed: *invertible = false; | 0 |
162 | return QMatrix4x4(); never executed: return QMatrix4x4(); | 0 |
163 | } | - |
164 | det = 1.0f / det; | - |
165 | | - |
166 | inv.m[0][0] = matrixDet2(mm, 1, 2, 1, 2) * det; | - |
167 | inv.m[0][1] = -matrixDet2(mm, 0, 2, 1, 2) * det; | - |
168 | inv.m[0][2] = matrixDet2(mm, 0, 1, 1, 2) * det; | - |
169 | inv.m[0][3] = 0; | - |
170 | inv.m[1][0] = -matrixDet2(mm, 1, 2, 0, 2) * det; | - |
171 | inv.m[1][1] = matrixDet2(mm, 0, 2, 0, 2) * det; | - |
172 | inv.m[1][2] = -matrixDet2(mm, 0, 1, 0, 2) * det; | - |
173 | inv.m[1][3] = 0; | - |
174 | inv.m[2][0] = matrixDet2(mm, 1, 2, 0, 1) * det; | - |
175 | inv.m[2][1] = -matrixDet2(mm, 0, 2, 0, 1) * det; | - |
176 | inv.m[2][2] = matrixDet2(mm, 0, 1, 0, 1) * det; | - |
177 | inv.m[2][3] = 0; | - |
178 | inv.m[3][0] = -inv.m[0][0] * m[3][0] - inv.m[1][0] * m[3][1] - inv.m[2][0] * m[3][2]; | - |
179 | inv.m[3][1] = -inv.m[0][1] * m[3][0] - inv.m[1][1] * m[3][1] - inv.m[2][1] * m[3][2]; | - |
180 | inv.m[3][2] = -inv.m[0][2] * m[3][0] - inv.m[1][2] * m[3][1] - inv.m[2][2] * m[3][2]; | - |
181 | inv.m[3][3] = 1; | - |
182 | inv.flagBits = flagBits; | - |
183 | | - |
184 | if (invertible) partially evaluated: invertible yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
185 | *invertible = true; executed: *invertible = true; Execution Count:1 | 1 |
186 | return inv; executed: return inv; Execution Count:1 | 1 |
187 | } | - |
188 | | - |
189 | QMatrix4x4 inv(1); | - |
190 | | - |
191 | double mm[4][4]; | - |
192 | copyToDoubles(m, mm); | - |
193 | | - |
194 | double det = matrixDet4(mm); | - |
195 | if (det == 0.0f) { evaluated: det == 0.0f yes Evaluation Count:4 | yes Evaluation Count:7 |
| 4-7 |
196 | if (invertible) partially evaluated: invertible yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
197 | *invertible = false; executed: *invertible = false; Execution Count:4 | 4 |
198 | return QMatrix4x4(); executed: return QMatrix4x4(); Execution Count:4 | 4 |
199 | } | - |
200 | det = 1.0f / det; | - |
201 | | - |
202 | inv.m[0][0] = matrixDet3(mm, 1, 2, 3, 1, 2, 3) * det; | - |
203 | inv.m[0][1] = -matrixDet3(mm, 0, 2, 3, 1, 2, 3) * det; | - |
204 | inv.m[0][2] = matrixDet3(mm, 0, 1, 3, 1, 2, 3) * det; | - |
205 | inv.m[0][3] = -matrixDet3(mm, 0, 1, 2, 1, 2, 3) * det; | - |
206 | inv.m[1][0] = -matrixDet3(mm, 1, 2, 3, 0, 2, 3) * det; | - |
207 | inv.m[1][1] = matrixDet3(mm, 0, 2, 3, 0, 2, 3) * det; | - |
208 | inv.m[1][2] = -matrixDet3(mm, 0, 1, 3, 0, 2, 3) * det; | - |
209 | inv.m[1][3] = matrixDet3(mm, 0, 1, 2, 0, 2, 3) * det; | - |
210 | inv.m[2][0] = matrixDet3(mm, 1, 2, 3, 0, 1, 3) * det; | - |
211 | inv.m[2][1] = -matrixDet3(mm, 0, 2, 3, 0, 1, 3) * det; | - |
212 | inv.m[2][2] = matrixDet3(mm, 0, 1, 3, 0, 1, 3) * det; | - |
213 | inv.m[2][3] = -matrixDet3(mm, 0, 1, 2, 0, 1, 3) * det; | - |
214 | inv.m[3][0] = -matrixDet3(mm, 1, 2, 3, 0, 1, 2) * det; | - |
215 | inv.m[3][1] = matrixDet3(mm, 0, 2, 3, 0, 1, 2) * det; | - |
216 | inv.m[3][2] = -matrixDet3(mm, 0, 1, 3, 0, 1, 2) * det; | - |
217 | inv.m[3][3] = matrixDet3(mm, 0, 1, 2, 0, 1, 2) * det; | - |
218 | inv.flagBits = flagBits; | - |
219 | | - |
220 | if (invertible) evaluated: invertible yes Evaluation Count:4 | yes Evaluation Count:3 |
| 3-4 |
221 | *invertible = true; executed: *invertible = true; Execution Count:4 | 4 |
222 | return inv; executed: return inv; Execution Count:7 | 7 |
223 | } | - |
224 | QMatrix3x3 QMatrix4x4::normalMatrix() const | - |
225 | { | - |
226 | QMatrix3x3 inv; | - |
227 | | - |
228 | | - |
229 | if (flagBits < Scale) { evaluated: flagBits < Scale yes Evaluation Count:2 | yes Evaluation Count:16 |
| 2-16 |
230 | | - |
231 | return inv; executed: return inv; Execution Count:2 | 2 |
232 | } else if (flagBits < Rotation2D) { evaluated: flagBits < Rotation2D yes Evaluation Count:5 | yes Evaluation Count:11 |
| 5-11 |
233 | | - |
234 | if (m[0][0] == 0.0f || m[1][1] == 0.0f || m[2][2] == 0.0f) evaluated: m[0][0] == 0.0f yes Evaluation Count:1 | yes Evaluation Count:4 |
evaluated: m[1][1] == 0.0f yes Evaluation Count:1 | yes Evaluation Count:3 |
evaluated: m[2][2] == 0.0f yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-4 |
235 | return inv; executed: return inv; Execution Count:3 | 3 |
236 | inv.data()[0] = 1.0f / m[0][0]; | - |
237 | inv.data()[4] = 1.0f / m[1][1]; | - |
238 | inv.data()[8] = 1.0f / m[2][2]; | - |
239 | return inv; executed: return inv; Execution Count:2 | 2 |
240 | } else if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity) { evaluated: (flagBits & ~(Translation | Rotation2D | Rotation)) == Identity yes Evaluation Count:1 | yes Evaluation Count:10 |
| 1-10 |
241 | float *invm = inv.data(); | - |
242 | invm[0 + 0 * 3] = m[0][0]; | - |
243 | invm[1 + 0 * 3] = m[0][1]; | - |
244 | invm[2 + 0 * 3] = m[0][2]; | - |
245 | invm[0 + 1 * 3] = m[1][0]; | - |
246 | invm[1 + 1 * 3] = m[1][1]; | - |
247 | invm[2 + 1 * 3] = m[1][2]; | - |
248 | invm[0 + 2 * 3] = m[2][0]; | - |
249 | invm[1 + 2 * 3] = m[2][1]; | - |
250 | invm[2 + 2 * 3] = m[2][2]; | - |
251 | return inv; executed: return inv; Execution Count:1 | 1 |
252 | } | - |
253 | | - |
254 | double mm[4][4]; | - |
255 | copyToDoubles(m, mm); | - |
256 | double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2); | - |
257 | if (det == 0.0f) evaluated: det == 0.0f yes Evaluation Count:5 | yes Evaluation Count:5 |
| 5 |
258 | return inv; executed: return inv; Execution Count:5 | 5 |
259 | det = 1.0f / det; | - |
260 | | - |
261 | float *invm = inv.data(); | - |
262 | | - |
263 | | - |
264 | invm[0 + 0 * 3] = (mm[1][1] * mm[2][2] - mm[2][1] * mm[1][2]) * det; | - |
265 | invm[1 + 0 * 3] = -(mm[1][0] * mm[2][2] - mm[1][2] * mm[2][0]) * det; | - |
266 | invm[2 + 0 * 3] = (mm[1][0] * mm[2][1] - mm[1][1] * mm[2][0]) * det; | - |
267 | invm[0 + 1 * 3] = -(mm[0][1] * mm[2][2] - mm[2][1] * mm[0][2]) * det; | - |
268 | invm[1 + 1 * 3] = (mm[0][0] * mm[2][2] - mm[0][2] * mm[2][0]) * det; | - |
269 | invm[2 + 1 * 3] = -(mm[0][0] * mm[2][1] - mm[0][1] * mm[2][0]) * det; | - |
270 | invm[0 + 2 * 3] = (mm[0][1] * mm[1][2] - mm[0][2] * mm[1][1]) * det; | - |
271 | invm[1 + 2 * 3] = -(mm[0][0] * mm[1][2] - mm[0][2] * mm[1][0]) * det; | - |
272 | invm[2 + 2 * 3] = (mm[0][0] * mm[1][1] - mm[1][0] * mm[0][1]) * det; | - |
273 | | - |
274 | return inv; executed: return inv; Execution Count:5 | 5 |
275 | } | - |
276 | | - |
277 | | - |
278 | | - |
279 | | - |
280 | QMatrix4x4 QMatrix4x4::transposed() const | - |
281 | { | - |
282 | QMatrix4x4 result(1); | - |
283 | for (int row = 0; row < 4; ++row) { evaluated: row < 4 yes Evaluation Count:12 | yes Evaluation Count:3 |
| 3-12 |
284 | for (int col = 0; col < 4; ++col) { evaluated: col < 4 yes Evaluation Count:48 | yes Evaluation Count:12 |
| 12-48 |
285 | result.m[col][row] = m[row][col]; | - |
286 | } executed: } Execution Count:48 | 48 |
287 | } executed: } Execution Count:12 | 12 |
288 | | - |
289 | result.flagBits = (flagBits & Translation ? General : flagBits); evaluated: flagBits & Translation yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
290 | return result; executed: return result; Execution Count:3 | 3 |
291 | } | - |
292 | QMatrix4x4& QMatrix4x4::operator/=(float divisor) | - |
293 | { | - |
294 | m[0][0] /= divisor; | - |
295 | m[0][1] /= divisor; | - |
296 | m[0][2] /= divisor; | - |
297 | m[0][3] /= divisor; | - |
298 | m[1][0] /= divisor; | - |
299 | m[1][1] /= divisor; | - |
300 | m[1][2] /= divisor; | - |
301 | m[1][3] /= divisor; | - |
302 | m[2][0] /= divisor; | - |
303 | m[2][1] /= divisor; | - |
304 | m[2][2] /= divisor; | - |
305 | m[2][3] /= divisor; | - |
306 | m[3][0] /= divisor; | - |
307 | m[3][1] /= divisor; | - |
308 | m[3][2] /= divisor; | - |
309 | m[3][3] /= divisor; | - |
310 | flagBits = General; | - |
311 | return *this; executed: return *this; Execution Count:4 | 4 |
312 | } | - |
313 | QMatrix4x4 operator/(const QMatrix4x4& matrix, float divisor) | - |
314 | { | - |
315 | QMatrix4x4 m(1); | - |
316 | m.m[0][0] = matrix.m[0][0] / divisor; | - |
317 | m.m[0][1] = matrix.m[0][1] / divisor; | - |
318 | m.m[0][2] = matrix.m[0][2] / divisor; | - |
319 | m.m[0][3] = matrix.m[0][3] / divisor; | - |
320 | m.m[1][0] = matrix.m[1][0] / divisor; | - |
321 | m.m[1][1] = matrix.m[1][1] / divisor; | - |
322 | m.m[1][2] = matrix.m[1][2] / divisor; | - |
323 | m.m[1][3] = matrix.m[1][3] / divisor; | - |
324 | m.m[2][0] = matrix.m[2][0] / divisor; | - |
325 | m.m[2][1] = matrix.m[2][1] / divisor; | - |
326 | m.m[2][2] = matrix.m[2][2] / divisor; | - |
327 | m.m[2][3] = matrix.m[2][3] / divisor; | - |
328 | m.m[3][0] = matrix.m[3][0] / divisor; | - |
329 | m.m[3][1] = matrix.m[3][1] / divisor; | - |
330 | m.m[3][2] = matrix.m[3][2] / divisor; | - |
331 | m.m[3][3] = matrix.m[3][3] / divisor; | - |
332 | m.flagBits = QMatrix4x4::General; | - |
333 | return m; executed: return m; Execution Count:4 | 4 |
334 | } | - |
335 | void QMatrix4x4::scale(const QVector3D& vector) | - |
336 | { | - |
337 | float vx = vector.x(); | - |
338 | float vy = vector.y(); | - |
339 | float vz = vector.z(); | - |
340 | if (flagBits < Scale) { evaluated: flagBits < Scale yes Evaluation Count:9 | yes Evaluation Count:7 |
| 7-9 |
341 | m[0][0] = vx; | - |
342 | m[1][1] = vy; | - |
343 | m[2][2] = vz; | - |
344 | } else if (flagBits < Rotation2D) { evaluated: flagBits < Rotation2D yes Evaluation Count:2 | yes Evaluation Count:5 |
executed: } Execution Count:9 | 2-9 |
345 | m[0][0] *= vx; | - |
346 | m[1][1] *= vy; | - |
347 | m[2][2] *= vz; | - |
348 | } else if (flagBits < Rotation) { partially evaluated: flagBits < Rotation no Evaluation Count:0 | yes Evaluation Count:5 |
executed: } Execution Count:2 | 0-5 |
349 | m[0][0] *= vx; | - |
350 | m[0][1] *= vx; | - |
351 | m[1][0] *= vy; | - |
352 | m[1][1] *= vy; | - |
353 | m[2][2] *= vz; | - |
354 | } else { | 0 |
355 | m[0][0] *= vx; | - |
356 | m[0][1] *= vx; | - |
357 | m[0][2] *= vx; | - |
358 | m[0][3] *= vx; | - |
359 | m[1][0] *= vy; | - |
360 | m[1][1] *= vy; | - |
361 | m[1][2] *= vy; | - |
362 | m[1][3] *= vy; | - |
363 | m[2][0] *= vz; | - |
364 | m[2][1] *= vz; | - |
365 | m[2][2] *= vz; | - |
366 | m[2][3] *= vz; | - |
367 | } executed: } Execution Count:5 | 5 |
368 | flagBits |= Scale; | - |
369 | } executed: } Execution Count:16 | 16 |
370 | void QMatrix4x4::scale(float x, float y) | - |
371 | { | - |
372 | if (flagBits < Scale) { evaluated: flagBits < Scale yes Evaluation Count:6 | yes Evaluation Count:2 |
| 2-6 |
373 | m[0][0] = x; | - |
374 | m[1][1] = y; | - |
375 | } else if (flagBits < Rotation2D) { partially evaluated: flagBits < Rotation2D no Evaluation Count:0 | yes Evaluation Count:2 |
executed: } Execution Count:6 | 0-6 |
376 | m[0][0] *= x; | - |
377 | m[1][1] *= y; | - |
378 | } else if (flagBits < Rotation) { partially evaluated: flagBits < Rotation no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
379 | m[0][0] *= x; | - |
380 | m[0][1] *= x; | - |
381 | m[1][0] *= y; | - |
382 | m[1][1] *= y; | - |
383 | } else { | 0 |
384 | m[0][0] *= x; | - |
385 | m[0][1] *= x; | - |
386 | m[0][2] *= x; | - |
387 | m[0][3] *= x; | - |
388 | m[1][0] *= y; | - |
389 | m[1][1] *= y; | - |
390 | m[1][2] *= y; | - |
391 | m[1][3] *= y; | - |
392 | } executed: } Execution Count:2 | 2 |
393 | flagBits |= Scale; | - |
394 | } executed: } Execution Count:8 | 8 |
395 | void QMatrix4x4::scale(float x, float y, float z) | - |
396 | { | - |
397 | if (flagBits < Scale) { evaluated: flagBits < Scale yes Evaluation Count:17 | yes Evaluation Count:12 |
| 12-17 |
398 | m[0][0] = x; | - |
399 | m[1][1] = y; | - |
400 | m[2][2] = z; | - |
401 | } else if (flagBits < Rotation2D) { evaluated: flagBits < Rotation2D yes Evaluation Count:2 | yes Evaluation Count:10 |
executed: } Execution Count:17 | 2-17 |
402 | m[0][0] *= x; | - |
403 | m[1][1] *= y; | - |
404 | m[2][2] *= z; | - |
405 | } else if (flagBits < Rotation) { partially evaluated: flagBits < Rotation no Evaluation Count:0 | yes Evaluation Count:10 |
executed: } Execution Count:2 | 0-10 |
406 | m[0][0] *= x; | - |
407 | m[0][1] *= x; | - |
408 | m[1][0] *= y; | - |
409 | m[1][1] *= y; | - |
410 | m[2][2] *= z; | - |
411 | } else { | 0 |
412 | m[0][0] *= x; | - |
413 | m[0][1] *= x; | - |
414 | m[0][2] *= x; | - |
415 | m[0][3] *= x; | - |
416 | m[1][0] *= y; | - |
417 | m[1][1] *= y; | - |
418 | m[1][2] *= y; | - |
419 | m[1][3] *= y; | - |
420 | m[2][0] *= z; | - |
421 | m[2][1] *= z; | - |
422 | m[2][2] *= z; | - |
423 | m[2][3] *= z; | - |
424 | } executed: } Execution Count:10 | 10 |
425 | flagBits |= Scale; | - |
426 | } executed: } Execution Count:29 | 29 |
427 | void QMatrix4x4::scale(float factor) | - |
428 | { | - |
429 | if (flagBits < Scale) { evaluated: flagBits < Scale yes Evaluation Count:8 | yes Evaluation Count:5 |
| 5-8 |
430 | m[0][0] = factor; | - |
431 | m[1][1] = factor; | - |
432 | m[2][2] = factor; | - |
433 | } else if (flagBits < Rotation2D) { evaluated: flagBits < Rotation2D yes Evaluation Count:2 | yes Evaluation Count:3 |
executed: } Execution Count:8 | 2-8 |
434 | m[0][0] *= factor; | - |
435 | m[1][1] *= factor; | - |
436 | m[2][2] *= factor; | - |
437 | } else if (flagBits < Rotation) { partially evaluated: flagBits < Rotation no Evaluation Count:0 | yes Evaluation Count:3 |
executed: } Execution Count:2 | 0-3 |
438 | m[0][0] *= factor; | - |
439 | m[0][1] *= factor; | - |
440 | m[1][0] *= factor; | - |
441 | m[1][1] *= factor; | - |
442 | m[2][2] *= factor; | - |
443 | } else { | 0 |
444 | m[0][0] *= factor; | - |
445 | m[0][1] *= factor; | - |
446 | m[0][2] *= factor; | - |
447 | m[0][3] *= factor; | - |
448 | m[1][0] *= factor; | - |
449 | m[1][1] *= factor; | - |
450 | m[1][2] *= factor; | - |
451 | m[1][3] *= factor; | - |
452 | m[2][0] *= factor; | - |
453 | m[2][1] *= factor; | - |
454 | m[2][2] *= factor; | - |
455 | m[2][3] *= factor; | - |
456 | } executed: } Execution Count:3 | 3 |
457 | flagBits |= Scale; | - |
458 | } executed: } Execution Count:13 | 13 |
459 | void QMatrix4x4::translate(const QVector3D& vector) | - |
460 | { | - |
461 | float vx = vector.x(); | - |
462 | float vy = vector.y(); | - |
463 | float vz = vector.z(); | - |
464 | if (flagBits == Identity) { evaluated: flagBits == Identity yes Evaluation Count:5777 | yes Evaluation Count:5773 |
| 5773-5777 |
465 | m[3][0] = vx; | - |
466 | m[3][1] = vy; | - |
467 | m[3][2] = vz; | - |
468 | } else if (flagBits == Translation) { evaluated: flagBits == Translation yes Evaluation Count:1 | yes Evaluation Count:5772 |
executed: } Execution Count:5777 | 1-5777 |
469 | m[3][0] += vx; | - |
470 | m[3][1] += vy; | - |
471 | m[3][2] += vz; | - |
472 | } else if (flagBits == Scale) { evaluated: flagBits == Scale yes Evaluation Count:1 | yes Evaluation Count:5771 |
executed: } Execution Count:1 | 1-5771 |
473 | m[3][0] = m[0][0] * vx; | - |
474 | m[3][1] = m[1][1] * vy; | - |
475 | m[3][2] = m[2][2] * vz; | - |
476 | } else if (flagBits == (Translation | Scale)) { evaluated: flagBits == (Translation | Scale) yes Evaluation Count:8 | yes Evaluation Count:5763 |
executed: } Execution Count:1 | 1-5763 |
477 | m[3][0] += m[0][0] * vx; | - |
478 | m[3][1] += m[1][1] * vy; | - |
479 | m[3][2] += m[2][2] * vz; | - |
480 | } else if (flagBits < Rotation) { evaluated: flagBits < Rotation yes Evaluation Count:723 | yes Evaluation Count:5040 |
executed: } Execution Count:8 | 8-5040 |
481 | m[3][0] += m[0][0] * vx + m[1][0] * vy; | - |
482 | m[3][1] += m[0][1] * vx + m[1][1] * vy; | - |
483 | m[3][2] += m[2][2] * vz; | - |
484 | } else { executed: } Execution Count:723 | 723 |
485 | m[3][0] += m[0][0] * vx + m[1][0] * vy + m[2][0] * vz; | - |
486 | m[3][1] += m[0][1] * vx + m[1][1] * vy + m[2][1] * vz; | - |
487 | m[3][2] += m[0][2] * vx + m[1][2] * vy + m[2][2] * vz; | - |
488 | m[3][3] += m[0][3] * vx + m[1][3] * vy + m[2][3] * vz; | - |
489 | } executed: } Execution Count:5040 | 5040 |
490 | flagBits |= Translation; | - |
491 | } executed: } Execution Count:11550 | 11550 |
492 | void QMatrix4x4::translate(float x, float y) | - |
493 | { | - |
494 | if (flagBits == Identity) { evaluated: flagBits == Identity yes Evaluation Count:6 | yes Evaluation Count:2 |
| 2-6 |
495 | m[3][0] = x; | - |
496 | m[3][1] = y; | - |
497 | } else if (flagBits == Translation) { partially evaluated: flagBits == Translation no Evaluation Count:0 | yes Evaluation Count:2 |
executed: } Execution Count:6 | 0-6 |
498 | m[3][0] += x; | - |
499 | m[3][1] += y; | - |
500 | } else if (flagBits == Scale) { partially evaluated: flagBits == Scale no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
501 | m[3][0] = m[0][0] * x; | - |
502 | m[3][1] = m[1][1] * y; | - |
503 | } else if (flagBits == (Translation | Scale)) { partially evaluated: flagBits == (Translation | Scale) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
504 | m[3][0] += m[0][0] * x; | - |
505 | m[3][1] += m[1][1] * y; | - |
506 | } else if (flagBits < Rotation) { partially evaluated: flagBits < Rotation no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
507 | m[3][0] += m[0][0] * x + m[1][0] * y; | - |
508 | m[3][1] += m[0][1] * x + m[1][1] * y; | - |
509 | } else { | 0 |
510 | m[3][0] += m[0][0] * x + m[1][0] * y; | - |
511 | m[3][1] += m[0][1] * x + m[1][1] * y; | - |
512 | m[3][2] += m[0][2] * x + m[1][2] * y; | - |
513 | m[3][3] += m[0][3] * x + m[1][3] * y; | - |
514 | } executed: } Execution Count:2 | 2 |
515 | flagBits |= Translation; | - |
516 | } executed: } Execution Count:8 | 8 |
517 | void QMatrix4x4::translate(float x, float y, float z) | - |
518 | { | - |
519 | if (flagBits == Identity) { evaluated: flagBits == Identity yes Evaluation Count:11 | yes Evaluation Count:9 |
| 9-11 |
520 | m[3][0] = x; | - |
521 | m[3][1] = y; | - |
522 | m[3][2] = z; | - |
523 | } else if (flagBits == Translation) { evaluated: flagBits == Translation yes Evaluation Count:1 | yes Evaluation Count:8 |
executed: } Execution Count:11 | 1-11 |
524 | m[3][0] += x; | - |
525 | m[3][1] += y; | - |
526 | m[3][2] += z; | - |
527 | } else if (flagBits == Scale) { evaluated: flagBits == Scale yes Evaluation Count:1 | yes Evaluation Count:7 |
executed: } Execution Count:1 | 1-7 |
528 | m[3][0] = m[0][0] * x; | - |
529 | m[3][1] = m[1][1] * y; | - |
530 | m[3][2] = m[2][2] * z; | - |
531 | } else if (flagBits == (Translation | Scale)) { evaluated: flagBits == (Translation | Scale) yes Evaluation Count:1 | yes Evaluation Count:6 |
executed: } Execution Count:1 | 1-6 |
532 | m[3][0] += m[0][0] * x; | - |
533 | m[3][1] += m[1][1] * y; | - |
534 | m[3][2] += m[2][2] * z; | - |
535 | } else if (flagBits < Rotation) { evaluated: flagBits < Rotation yes Evaluation Count:1 | yes Evaluation Count:5 |
executed: } Execution Count:1 | 1-5 |
536 | m[3][0] += m[0][0] * x + m[1][0] * y; | - |
537 | m[3][1] += m[0][1] * x + m[1][1] * y; | - |
538 | m[3][2] += m[2][2] * z; | - |
539 | } else { executed: } Execution Count:1 | 1 |
540 | m[3][0] += m[0][0] * x + m[1][0] * y + m[2][0] * z; | - |
541 | m[3][1] += m[0][1] * x + m[1][1] * y + m[2][1] * z; | - |
542 | m[3][2] += m[0][2] * x + m[1][2] * y + m[2][2] * z; | - |
543 | m[3][3] += m[0][3] * x + m[1][3] * y + m[2][3] * z; | - |
544 | } executed: } Execution Count:5 | 5 |
545 | flagBits |= Translation; | - |
546 | } executed: } Execution Count:20 | 20 |
547 | void QMatrix4x4::rotate(float angle, const QVector3D& vector) | - |
548 | { | - |
549 | rotate(angle, vector.x(), vector.y(), vector.z()); | - |
550 | } executed: } Execution Count:1814 | 1814 |
551 | void QMatrix4x4::rotate(float angle, float x, float y, float z) | - |
552 | { | - |
553 | if (angle == 0.0f) evaluated: angle == 0.0f yes Evaluation Count:8 | yes Evaluation Count:1831 |
| 8-1831 |
554 | return; executed: return; Execution Count:8 | 8 |
555 | float c, s; | - |
556 | if (angle == 90.0f || angle == -270.0f) { evaluated: angle == 90.0f yes Evaluation Count:27 | yes Evaluation Count:1804 |
partially evaluated: angle == -270.0f no Evaluation Count:0 | yes Evaluation Count:1804 |
| 0-1804 |
557 | s = 1.0f; | - |
558 | c = 0.0f; | - |
559 | } else if (angle == -90.0f || angle == 270.0f) { partially evaluated: angle == -90.0f no Evaluation Count:0 | yes Evaluation Count:1804 |
evaluated: angle == 270.0f yes Evaluation Count:5 | yes Evaluation Count:1799 |
executed: } Execution Count:27 | 0-1804 |
560 | s = -1.0f; | - |
561 | c = 0.0f; | - |
562 | } else if (angle == 180.0f || angle == -180.0f) { evaluated: angle == 180.0f yes Evaluation Count:5 | yes Evaluation Count:1794 |
partially evaluated: angle == -180.0f no Evaluation Count:0 | yes Evaluation Count:1794 |
executed: } Execution Count:5 | 0-1794 |
563 | s = 0.0f; | - |
564 | c = -1.0f; | - |
565 | } else { executed: } Execution Count:5 | 5 |
566 | float a = angle * 3.14159265358979323846 / 180.0f; | - |
567 | c = cosf(a); | - |
568 | s = sinf(a); | - |
569 | } executed: } Execution Count:1794 | 1794 |
570 | if (x == 0.0f) { evaluated: x == 0.0f yes Evaluation Count:20 | yes Evaluation Count:1811 |
| 20-1811 |
571 | if (y == 0.0f) { evaluated: y == 0.0f yes Evaluation Count:13 | yes Evaluation Count:7 |
| 7-13 |
572 | if (z != 0.0f) { evaluated: z != 0.0f yes Evaluation Count:10 | yes Evaluation Count:3 |
| 3-10 |
573 | | - |
574 | if (z < 0) evaluated: z < 0 yes Evaluation Count:3 | yes Evaluation Count:7 |
| 3-7 |
575 | s = -s; executed: s = -s; Execution Count:3 | 3 |
576 | float tmp; | - |
577 | m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s; | - |
578 | m[1][0] = m[1][0] * c - tmp * s; | - |
579 | m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s; | - |
580 | m[1][1] = m[1][1] * c - tmp * s; | - |
581 | m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s; | - |
582 | m[1][2] = m[1][2] * c - tmp * s; | - |
583 | m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s; | - |
584 | m[1][3] = m[1][3] * c - tmp * s; | - |
585 | | - |
586 | flagBits |= Rotation2D; | - |
587 | return; executed: return; Execution Count:10 | 10 |
588 | } | - |
589 | } else if (z == 0.0f) { partially evaluated: z == 0.0f yes Evaluation Count:7 | no Evaluation Count:0 |
executed: } Execution Count:3 | 0-7 |
590 | | - |
591 | if (y < 0) evaluated: y < 0 yes Evaluation Count:3 | yes Evaluation Count:4 |
| 3-4 |
592 | s = -s; executed: s = -s; Execution Count:3 | 3 |
593 | float tmp; | - |
594 | m[2][0] = (tmp = m[2][0]) * c + m[0][0] * s; | - |
595 | m[0][0] = m[0][0] * c - tmp * s; | - |
596 | m[2][1] = (tmp = m[2][1]) * c + m[0][1] * s; | - |
597 | m[0][1] = m[0][1] * c - tmp * s; | - |
598 | m[2][2] = (tmp = m[2][2]) * c + m[0][2] * s; | - |
599 | m[0][2] = m[0][2] * c - tmp * s; | - |
600 | m[2][3] = (tmp = m[2][3]) * c + m[0][3] * s; | - |
601 | m[0][3] = m[0][3] * c - tmp * s; | - |
602 | | - |
603 | flagBits |= Rotation; | - |
604 | return; executed: return; Execution Count:7 | 7 |
605 | } | - |
606 | } else if (y == 0.0f && z == 0.0f) { evaluated: y == 0.0f yes Evaluation Count:368 | yes Evaluation Count:1443 |
evaluated: z == 0.0f yes Evaluation Count:8 | yes Evaluation Count:360 |
| 8-1443 |
607 | | - |
608 | if (x < 0) evaluated: x < 0 yes Evaluation Count:3 | yes Evaluation Count:5 |
| 3-5 |
609 | s = -s; executed: s = -s; Execution Count:3 | 3 |
610 | float tmp; | - |
611 | m[1][0] = (tmp = m[1][0]) * c + m[2][0] * s; | - |
612 | m[2][0] = m[2][0] * c - tmp * s; | - |
613 | m[1][1] = (tmp = m[1][1]) * c + m[2][1] * s; | - |
614 | m[2][1] = m[2][1] * c - tmp * s; | - |
615 | m[1][2] = (tmp = m[1][2]) * c + m[2][2] * s; | - |
616 | m[2][2] = m[2][2] * c - tmp * s; | - |
617 | m[1][3] = (tmp = m[1][3]) * c + m[2][3] * s; | - |
618 | m[2][3] = m[2][3] * c - tmp * s; | - |
619 | | - |
620 | flagBits |= Rotation; | - |
621 | return; executed: return; Execution Count:8 | 8 |
622 | } | - |
623 | | - |
624 | double len = double(x) * double(x) + | - |
625 | double(y) * double(y) + | - |
626 | double(z) * double(z); | - |
627 | if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) { partially evaluated: !qFuzzyCompare(len, 1.0) yes Evaluation Count:1806 | no Evaluation Count:0 |
evaluated: !qFuzzyIsNull(len) yes Evaluation Count:1803 | yes Evaluation Count:3 |
| 0-1806 |
628 | len = sqrt(len); | - |
629 | x = float(double(x) / len); | - |
630 | y = float(double(y) / len); | - |
631 | z = float(double(z) / len); | - |
632 | } executed: } Execution Count:1803 | 1803 |
633 | float ic = 1.0f - c; | - |
634 | QMatrix4x4 rot(1); | - |
635 | rot.m[0][0] = x * x * ic + c; | - |
636 | rot.m[1][0] = x * y * ic - z * s; | - |
637 | rot.m[2][0] = x * z * ic + y * s; | - |
638 | rot.m[3][0] = 0.0f; | - |
639 | rot.m[0][1] = y * x * ic + z * s; | - |
640 | rot.m[1][1] = y * y * ic + c; | - |
641 | rot.m[2][1] = y * z * ic - x * s; | - |
642 | rot.m[3][1] = 0.0f; | - |
643 | rot.m[0][2] = x * z * ic - y * s; | - |
644 | rot.m[1][2] = y * z * ic + x * s; | - |
645 | rot.m[2][2] = z * z * ic + c; | - |
646 | rot.m[3][2] = 0.0f; | - |
647 | rot.m[0][3] = 0.0f; | - |
648 | rot.m[1][3] = 0.0f; | - |
649 | rot.m[2][3] = 0.0f; | - |
650 | rot.m[3][3] = 1.0f; | - |
651 | rot.flagBits = Rotation; | - |
652 | *this *= rot; | - |
653 | } executed: } Execution Count:1806 | 1806 |
654 | | - |
655 | | - |
656 | | - |
657 | | - |
658 | void QMatrix4x4::projectedRotate(float angle, float x, float y, float z) | - |
659 | { | - |
660 | | - |
661 | | - |
662 | if (angle == 0.0f) partially evaluated: angle == 0.0f no Evaluation Count:0 | yes Evaluation Count:5763 |
| 0-5763 |
663 | return; | 0 |
664 | float c, s; | - |
665 | if (angle == 90.0f || angle == -270.0f) { evaluated: angle == 90.0f yes Evaluation Count:18 | yes Evaluation Count:5745 |
partially evaluated: angle == -270.0f no Evaluation Count:0 | yes Evaluation Count:5745 |
| 0-5745 |
666 | s = 1.0f; | - |
667 | c = 0.0f; | - |
668 | } else if (angle == -90.0f || angle == 270.0f) { executed: } Execution Count:18 partially evaluated: angle == -90.0f no Evaluation Count:0 | yes Evaluation Count:5745 |
evaluated: angle == 270.0f yes Evaluation Count:16 | yes Evaluation Count:5729 |
| 0-5745 |
669 | s = -1.0f; | - |
670 | c = 0.0f; | - |
671 | } else if (angle == 180.0f || angle == -180.0f) { executed: } Execution Count:16 evaluated: angle == 180.0f yes Evaluation Count:16 | yes Evaluation Count:5713 |
partially evaluated: angle == -180.0f no Evaluation Count:0 | yes Evaluation Count:5713 |
| 0-5713 |
672 | s = 0.0f; | - |
673 | c = -1.0f; | - |
674 | } else { executed: } Execution Count:16 | 16 |
675 | float a = angle * 3.14159265358979323846 / 180.0f; | - |
676 | c = cosf(a); | - |
677 | s = sinf(a); | - |
678 | } executed: } Execution Count:5713 | 5713 |
679 | if (x == 0.0f) { evaluated: x == 0.0f yes Evaluation Count:1443 | yes Evaluation Count:4320 |
| 1443-4320 |
680 | if (y == 0.0f) { evaluated: y == 0.0f yes Evaluation Count:723 | yes Evaluation Count:720 |
| 720-723 |
681 | if (z != 0.0f) { partially evaluated: z != 0.0f yes Evaluation Count:723 | no Evaluation Count:0 |
| 0-723 |
682 | | - |
683 | if (z < 0) partially evaluated: z < 0 no Evaluation Count:0 | yes Evaluation Count:723 |
| 0-723 |
684 | s = -s; | 0 |
685 | float tmp; | - |
686 | m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s; | - |
687 | m[1][0] = m[1][0] * c - tmp * s; | - |
688 | m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s; | - |
689 | m[1][1] = m[1][1] * c - tmp * s; | - |
690 | m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s; | - |
691 | m[1][2] = m[1][2] * c - tmp * s; | - |
692 | m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s; | - |
693 | m[1][3] = m[1][3] * c - tmp * s; | - |
694 | | - |
695 | flagBits |= Rotation2D; | - |
696 | return; executed: return; Execution Count:723 | 723 |
697 | } | - |
698 | } else if (z == 0.0f) { partially evaluated: z == 0.0f yes Evaluation Count:720 | no Evaluation Count:0 |
| 0-720 |
699 | | - |
700 | if (y < 0) partially evaluated: y < 0 no Evaluation Count:0 | yes Evaluation Count:720 |
| 0-720 |
701 | s = -s; | 0 |
702 | m[0][0] = m[0][0] * c + m[3][0] * s * inv_dist_to_plane; | - |
703 | m[0][1] = m[0][1] * c + m[3][1] * s * inv_dist_to_plane; | - |
704 | m[0][2] = m[0][2] * c + m[3][2] * s * inv_dist_to_plane; | - |
705 | m[0][3] = m[0][3] * c + m[3][3] * s * inv_dist_to_plane; | - |
706 | flagBits = General; | - |
707 | return; executed: return; Execution Count:720 | 720 |
708 | } | - |
709 | } else if (y == 0.0f && z == 0.0f) { evaluated: y == 0.0f yes Evaluation Count:1440 | yes Evaluation Count:2880 |
evaluated: z == 0.0f yes Evaluation Count:720 | yes Evaluation Count:720 |
| 720-2880 |
710 | | - |
711 | if (x < 0) partially evaluated: x < 0 no Evaluation Count:0 | yes Evaluation Count:720 |
| 0-720 |
712 | s = -s; | 0 |
713 | m[1][0] = m[1][0] * c - m[3][0] * s * inv_dist_to_plane; | - |
714 | m[1][1] = m[1][1] * c - m[3][1] * s * inv_dist_to_plane; | - |
715 | m[1][2] = m[1][2] * c - m[3][2] * s * inv_dist_to_plane; | - |
716 | m[1][3] = m[1][3] * c - m[3][3] * s * inv_dist_to_plane; | - |
717 | flagBits = General; | - |
718 | return; executed: return; Execution Count:720 | 720 |
719 | } | - |
720 | double len = double(x) * double(x) + | - |
721 | double(y) * double(y) + | - |
722 | double(z) * double(z); | - |
723 | if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) { partially evaluated: !qFuzzyCompare(len, 1.0) yes Evaluation Count:3600 | no Evaluation Count:0 |
partially evaluated: !qFuzzyIsNull(len) yes Evaluation Count:3600 | no Evaluation Count:0 |
| 0-3600 |
724 | len = sqrt(len); | - |
725 | x = float(double(x) / len); | - |
726 | y = float(double(y) / len); | - |
727 | z = float(double(z) / len); | - |
728 | } executed: } Execution Count:3600 | 3600 |
729 | float ic = 1.0f - c; | - |
730 | QMatrix4x4 rot(1); | - |
731 | rot.m[0][0] = x * x * ic + c; | - |
732 | rot.m[1][0] = x * y * ic - z * s; | - |
733 | rot.m[2][0] = 0.0f; | - |
734 | rot.m[3][0] = 0.0f; | - |
735 | rot.m[0][1] = y * x * ic + z * s; | - |
736 | rot.m[1][1] = y * y * ic + c; | - |
737 | rot.m[2][1] = 0.0f; | - |
738 | rot.m[3][1] = 0.0f; | - |
739 | rot.m[0][2] = 0.0f; | - |
740 | rot.m[1][2] = 0.0f; | - |
741 | rot.m[2][2] = 1.0f; | - |
742 | rot.m[3][2] = 0.0f; | - |
743 | rot.m[0][3] = (x * z * ic - y * s) * -inv_dist_to_plane; | - |
744 | rot.m[1][3] = (y * z * ic + x * s) * -inv_dist_to_plane; | - |
745 | rot.m[2][3] = 0.0f; | - |
746 | rot.m[3][3] = 1.0f; | - |
747 | rot.flagBits = General; | - |
748 | *this *= rot; | - |
749 | } executed: } Execution Count:3600 | 3600 |
750 | void QMatrix4x4::rotate(const QQuaternion& quaternion) | - |
751 | { | - |
752 | | - |
753 | | - |
754 | QMatrix4x4 m(1); | - |
755 | float xx = quaternion.x() * quaternion.x(); | - |
756 | float xy = quaternion.x() * quaternion.y(); | - |
757 | float xz = quaternion.x() * quaternion.z(); | - |
758 | float xw = quaternion.x() * quaternion.scalar(); | - |
759 | float yy = quaternion.y() * quaternion.y(); | - |
760 | float yz = quaternion.y() * quaternion.z(); | - |
761 | float yw = quaternion.y() * quaternion.scalar(); | - |
762 | float zz = quaternion.z() * quaternion.z(); | - |
763 | float zw = quaternion.z() * quaternion.scalar(); | - |
764 | m.m[0][0] = 1.0f - 2 * (yy + zz); | - |
765 | m.m[1][0] = 2 * (xy - zw); | - |
766 | m.m[2][0] = 2 * (xz + yw); | - |
767 | m.m[3][0] = 0.0f; | - |
768 | m.m[0][1] = 2 * (xy + zw); | - |
769 | m.m[1][1] = 1.0f - 2 * (xx + zz); | - |
770 | m.m[2][1] = 2 * (yz - xw); | - |
771 | m.m[3][1] = 0.0f; | - |
772 | m.m[0][2] = 2 * (xz - yw); | - |
773 | m.m[1][2] = 2 * (yz + xw); | - |
774 | m.m[2][2] = 1.0f - 2 * (xx + yy); | - |
775 | m.m[3][2] = 0.0f; | - |
776 | m.m[0][3] = 0.0f; | - |
777 | m.m[1][3] = 0.0f; | - |
778 | m.m[2][3] = 0.0f; | - |
779 | m.m[3][3] = 1.0f; | - |
780 | m.flagBits = Rotation; | - |
781 | *this *= m; | - |
782 | } executed: } Execution Count:8 | 8 |
783 | void QMatrix4x4::ortho(const QRect& rect) | - |
784 | { | - |
785 | | - |
786 | | - |
787 | | - |
788 | | - |
789 | ortho(rect.x(), rect.x() + rect.width(), rect.y() + rect.height(), rect.y(), -1.0f, 1.0f); | - |
790 | } executed: } Execution Count:1 | 1 |
791 | void QMatrix4x4::ortho(const QRectF& rect) | - |
792 | { | - |
793 | ortho(rect.left(), rect.right(), rect.bottom(), rect.top(), -1.0f, 1.0f); | - |
794 | } executed: } Execution Count:1 | 1 |
795 | void QMatrix4x4::ortho(float left, float right, float bottom, float top, float nearPlane, float farPlane) | - |
796 | { | - |
797 | | - |
798 | if (left == right || bottom == top || nearPlane == farPlane) evaluated: left == right yes Evaluation Count:1 | yes Evaluation Count:6 |
evaluated: bottom == top yes Evaluation Count:1 | yes Evaluation Count:5 |
evaluated: nearPlane == farPlane yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-6 |
799 | return; executed: return; Execution Count:3 | 3 |
800 | | - |
801 | | - |
802 | float width = right - left; | - |
803 | float invheight = top - bottom; | - |
804 | float clip = farPlane - nearPlane; | - |
805 | QMatrix4x4 m(1); | - |
806 | m.m[0][0] = 2.0f / width; | - |
807 | m.m[1][0] = 0.0f; | - |
808 | m.m[2][0] = 0.0f; | - |
809 | m.m[3][0] = -(left + right) / width; | - |
810 | m.m[0][1] = 0.0f; | - |
811 | m.m[1][1] = 2.0f / invheight; | - |
812 | m.m[2][1] = 0.0f; | - |
813 | m.m[3][1] = -(top + bottom) / invheight; | - |
814 | m.m[0][2] = 0.0f; | - |
815 | m.m[1][2] = 0.0f; | - |
816 | m.m[2][2] = -2.0f / clip; | - |
817 | m.m[3][2] = -(nearPlane + farPlane) / clip; | - |
818 | m.m[0][3] = 0.0f; | - |
819 | m.m[1][3] = 0.0f; | - |
820 | m.m[2][3] = 0.0f; | - |
821 | m.m[3][3] = 1.0f; | - |
822 | m.flagBits = Translation | Scale; | - |
823 | | - |
824 | | - |
825 | *this *= m; | - |
826 | } executed: } Execution Count:4 | 4 |
827 | void QMatrix4x4::frustum(float left, float right, float bottom, float top, float nearPlane, float farPlane) | - |
828 | { | - |
829 | | - |
830 | if (left == right || bottom == top || nearPlane == farPlane) evaluated: left == right yes Evaluation Count:1 | yes Evaluation Count:3 |
evaluated: bottom == top yes Evaluation Count:1 | yes Evaluation Count:2 |
evaluated: nearPlane == farPlane yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-3 |
831 | return; executed: return; Execution Count:3 | 3 |
832 | | - |
833 | | - |
834 | QMatrix4x4 m(1); | - |
835 | float width = right - left; | - |
836 | float invheight = top - bottom; | - |
837 | float clip = farPlane - nearPlane; | - |
838 | m.m[0][0] = 2.0f * nearPlane / width; | - |
839 | m.m[1][0] = 0.0f; | - |
840 | m.m[2][0] = (left + right) / width; | - |
841 | m.m[3][0] = 0.0f; | - |
842 | m.m[0][1] = 0.0f; | - |
843 | m.m[1][1] = 2.0f * nearPlane / invheight; | - |
844 | m.m[2][1] = (top + bottom) / invheight; | - |
845 | m.m[3][1] = 0.0f; | - |
846 | m.m[0][2] = 0.0f; | - |
847 | m.m[1][2] = 0.0f; | - |
848 | m.m[2][2] = -(nearPlane + farPlane) / clip; | - |
849 | m.m[3][2] = -2.0f * nearPlane * farPlane / clip; | - |
850 | m.m[0][3] = 0.0f; | - |
851 | m.m[1][3] = 0.0f; | - |
852 | m.m[2][3] = -1.0f; | - |
853 | m.m[3][3] = 0.0f; | - |
854 | m.flagBits = General; | - |
855 | | - |
856 | | - |
857 | *this *= m; | - |
858 | } executed: } Execution Count:1 | 1 |
859 | void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearPlane, float farPlane) | - |
860 | { | - |
861 | | - |
862 | if (nearPlane == farPlane || aspectRatio == 0.0f) evaluated: nearPlane == farPlane yes Evaluation Count:1 | yes Evaluation Count:3 |
evaluated: aspectRatio == 0.0f yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-3 |
863 | return; executed: return; Execution Count:2 | 2 |
864 | | - |
865 | | - |
866 | QMatrix4x4 m(1); | - |
867 | float radians = (verticalAngle / 2.0f) * 3.14159265358979323846 / 180.0f; | - |
868 | float sine = sinf(radians); | - |
869 | if (sine == 0.0f) evaluated: sine == 0.0f yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
870 | return; executed: return; Execution Count:1 | 1 |
871 | float cotan = cosf(radians) / sine; | - |
872 | float clip = farPlane - nearPlane; | - |
873 | m.m[0][0] = cotan / aspectRatio; | - |
874 | m.m[1][0] = 0.0f; | - |
875 | m.m[2][0] = 0.0f; | - |
876 | m.m[3][0] = 0.0f; | - |
877 | m.m[0][1] = 0.0f; | - |
878 | m.m[1][1] = cotan; | - |
879 | m.m[2][1] = 0.0f; | - |
880 | m.m[3][1] = 0.0f; | - |
881 | m.m[0][2] = 0.0f; | - |
882 | m.m[1][2] = 0.0f; | - |
883 | m.m[2][2] = -(nearPlane + farPlane) / clip; | - |
884 | m.m[3][2] = -(2.0f * nearPlane * farPlane) / clip; | - |
885 | m.m[0][3] = 0.0f; | - |
886 | m.m[1][3] = 0.0f; | - |
887 | m.m[2][3] = -1.0f; | - |
888 | m.m[3][3] = 0.0f; | - |
889 | m.flagBits = General; | - |
890 | | - |
891 | | - |
892 | *this *= m; | - |
893 | } executed: } Execution Count:1 | 1 |
894 | void QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up) | - |
895 | { | - |
896 | QVector3D forward = (center - eye).normalized(); | - |
897 | QVector3D side = QVector3D::crossProduct(forward, up).normalized(); | - |
898 | QVector3D upVector = QVector3D::crossProduct(side, forward); | - |
899 | | - |
900 | QMatrix4x4 m(1); | - |
901 | m.m[0][0] = side.x(); | - |
902 | m.m[1][0] = side.y(); | - |
903 | m.m[2][0] = side.z(); | - |
904 | m.m[3][0] = 0.0f; | - |
905 | m.m[0][1] = upVector.x(); | - |
906 | m.m[1][1] = upVector.y(); | - |
907 | m.m[2][1] = upVector.z(); | - |
908 | m.m[3][1] = 0.0f; | - |
909 | m.m[0][2] = -forward.x(); | - |
910 | m.m[1][2] = -forward.y(); | - |
911 | m.m[2][2] = -forward.z(); | - |
912 | m.m[3][2] = 0.0f; | - |
913 | m.m[0][3] = 0.0f; | - |
914 | m.m[1][3] = 0.0f; | - |
915 | m.m[2][3] = 0.0f; | - |
916 | m.m[3][3] = 1.0f; | - |
917 | m.flagBits = Rotation; | - |
918 | | - |
919 | *this *= m; | - |
920 | translate(-eye); | - |
921 | } | 0 |
922 | void QMatrix4x4::flipCoordinates() | - |
923 | { | - |
924 | | - |
925 | | - |
926 | | - |
927 | if (flagBits < Rotation2D) { evaluated: flagBits < Rotation2D yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
928 | | - |
929 | m[1][1] = -m[1][1]; | - |
930 | m[2][2] = -m[2][2]; | - |
931 | } else { executed: } Execution Count:3 | 3 |
932 | m[1][0] = -m[1][0]; | - |
933 | m[1][1] = -m[1][1]; | - |
934 | m[1][2] = -m[1][2]; | - |
935 | m[1][3] = -m[1][3]; | - |
936 | m[2][0] = -m[2][0]; | - |
937 | m[2][1] = -m[2][1]; | - |
938 | m[2][2] = -m[2][2]; | - |
939 | m[2][3] = -m[2][3]; | - |
940 | } executed: } Execution Count:1 | 1 |
941 | flagBits |= Scale; | - |
942 | } executed: } Execution Count:4 | 4 |
943 | | - |
944 | | - |
945 | | - |
946 | | - |
947 | | - |
948 | void QMatrix4x4::copyDataTo(float *values) const | - |
949 | { | - |
950 | for (int row = 0; row < 4; ++row) evaluated: row < 4 yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
951 | for (int col = 0; col < 4; ++col) evaluated: col < 4 yes Evaluation Count:16 | yes Evaluation Count:4 |
| 4-16 |
952 | values[row * 4 + col] = float(m[col][row]); executed: values[row * 4 + col] = float(m[col][row]); Execution Count:16 | 16 |
953 | } executed: } Execution Count:1 | 1 |
954 | QMatrix QMatrix4x4::toAffine() const | - |
955 | { | - |
956 | return QMatrix(m[0][0], m[0][1], | 3 |
957 | m[1][0], m[1][1], | 3 |
958 | m[3][0], m[3][1]); executed: return QMatrix(m[0][0], m[0][1], m[1][0], m[1][1], m[3][0], m[3][1]); Execution Count:3 | 3 |
959 | } | - |
960 | QTransform QMatrix4x4::toTransform() const | - |
961 | { | - |
962 | return QTransform(m[0][0], m[0][1], m[0][3], | 9039 |
963 | m[1][0], m[1][1], m[1][3], | 9039 |
964 | m[3][0], m[3][1], m[3][3]); executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); Execution Count:9039 | 9039 |
965 | } | - |
966 | QTransform QMatrix4x4::toTransform(float distanceToPlane) const | - |
967 | { | - |
968 | if (distanceToPlane == 1024.0f) { partially evaluated: distanceToPlane == 1024.0f yes Evaluation Count:1805 | no Evaluation Count:0 |
| 0-1805 |
969 | | - |
970 | return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * inv_dist_to_plane, | 1805 |
971 | m[1][0], m[1][1], m[1][3] - m[1][2] * inv_dist_to_plane, | 1805 |
972 | m[3][0], m[3][1], m[3][3] - m[3][2] * inv_dist_to_plane); executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * inv_dist_to_plane, m[1][0], m[1][1], m[1][3] - m[1][2] * inv_dist_to_plane, m[3][0], m[3][1], m[3][3] - m[3][2] * inv_dist_to_plane); Execution Count:1805 | 1805 |
973 | } else if (distanceToPlane != 0.0f) { never evaluated: distanceToPlane != 0.0f | 0 |
974 | | - |
975 | | - |
976 | | - |
977 | | - |
978 | | - |
979 | | - |
980 | | - |
981 | float d = 1.0f / distanceToPlane; | - |
982 | return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * d, | 0 |
983 | m[1][0], m[1][1], m[1][3] - m[1][2] * d, | 0 |
984 | m[3][0], m[3][1], m[3][3] - m[3][2] * d); never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * d, m[1][0], m[1][1], m[1][3] - m[1][2] * d, m[3][0], m[3][1], m[3][3] - m[3][2] * d); | 0 |
985 | } else { | - |
986 | | - |
987 | return QTransform(m[0][0], m[0][1], m[0][3], | 0 |
988 | m[1][0], m[1][1], m[1][3], | 0 |
989 | m[3][0], m[3][1], m[3][3]); never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); | 0 |
990 | } | - |
991 | } | - |
992 | QRect QMatrix4x4::mapRect(const QRect& rect) const | - |
993 | { | - |
994 | if (flagBits < Scale) { evaluated: flagBits < Scale yes Evaluation Count:4 | yes Evaluation Count:6 |
| 4-6 |
995 | | - |
996 | return QRect(qRound(rect.x() + m[3][0]), | 4 |
997 | qRound(rect.y() + m[3][1]), | 4 |
998 | rect.width(), rect.height()); executed: return QRect(qRound(rect.x() + m[3][0]), qRound(rect.y() + m[3][1]), rect.width(), rect.height()); Execution Count:4 | 4 |
999 | } else if (flagBits < Rotation2D) { evaluated: flagBits < Rotation2D yes Evaluation Count:4 | yes Evaluation Count:2 |
| 2-4 |
1000 | | - |
1001 | float x = rect.x() * m[0][0] + m[3][0]; | - |
1002 | float y = rect.y() * m[1][1] + m[3][1]; | - |
1003 | float w = rect.width() * m[0][0]; | - |
1004 | float h = rect.height() * m[1][1]; | - |
1005 | if (w < 0) { evaluated: w < 0 yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
1006 | w = -w; | - |
1007 | x -= w; | - |
1008 | } executed: } Execution Count:2 | 2 |
1009 | if (h < 0) { partially evaluated: h < 0 no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1010 | h = -h; | - |
1011 | y -= h; | - |
1012 | } | 0 |
1013 | return QRect(qRound(x), qRound(y), qRound(w), qRound(h)); executed: return QRect(qRound(x), qRound(y), qRound(w), qRound(h)); Execution Count:4 | 4 |
1014 | } | - |
1015 | | - |
1016 | QPoint tl = map(rect.topLeft()); | - |
1017 | QPoint tr = map(QPoint(rect.x() + rect.width(), rect.y())); | - |
1018 | QPoint bl = map(QPoint(rect.x(), rect.y() + rect.height())); | - |
1019 | QPoint br = map(QPoint(rect.x() + rect.width(), | - |
1020 | rect.y() + rect.height())); | - |
1021 | | - |
1022 | int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); | - |
1023 | int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); | - |
1024 | int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); | - |
1025 | int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); | - |
1026 | | - |
1027 | return QRect(xmin, ymin, xmax - xmin, ymax - ymin); executed: return QRect(xmin, ymin, xmax - xmin, ymax - ymin); Execution Count:2 | 2 |
1028 | } | - |
1029 | QRectF QMatrix4x4::mapRect(const QRectF& rect) const | - |
1030 | { | - |
1031 | if (flagBits < Scale) { evaluated: flagBits < Scale yes Evaluation Count:4 | yes Evaluation Count:6 |
| 4-6 |
1032 | | - |
1033 | return rect.translated(m[3][0], m[3][1]); executed: return rect.translated(m[3][0], m[3][1]); Execution Count:4 | 4 |
1034 | } else if (flagBits < Rotation2D) { evaluated: flagBits < Rotation2D yes Evaluation Count:4 | yes Evaluation Count:2 |
| 2-4 |
1035 | | - |
1036 | float x = rect.x() * m[0][0] + m[3][0]; | - |
1037 | float y = rect.y() * m[1][1] + m[3][1]; | - |
1038 | float w = rect.width() * m[0][0]; | - |
1039 | float h = rect.height() * m[1][1]; | - |
1040 | if (w < 0) { evaluated: w < 0 yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
1041 | w = -w; | - |
1042 | x -= w; | - |
1043 | } executed: } Execution Count:2 | 2 |
1044 | if (h < 0) { partially evaluated: h < 0 no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1045 | h = -h; | - |
1046 | y -= h; | - |
1047 | } | 0 |
1048 | return QRectF(x, y, w, h); executed: return QRectF(x, y, w, h); Execution Count:4 | 4 |
1049 | } | - |
1050 | | - |
1051 | QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight()); | - |
1052 | QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight()); | - |
1053 | | - |
1054 | float xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x())); | - |
1055 | float xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x())); | - |
1056 | float ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y())); | - |
1057 | float ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y())); | - |
1058 | | - |
1059 | return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); executed: return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)); Execution Count:2 | 2 |
1060 | } | - |
1061 | QMatrix4x4 QMatrix4x4::orthonormalInverse() const | - |
1062 | { | - |
1063 | QMatrix4x4 result(1); | - |
1064 | | - |
1065 | result.m[0][0] = m[0][0]; | - |
1066 | result.m[1][0] = m[0][1]; | - |
1067 | result.m[2][0] = m[0][2]; | - |
1068 | | - |
1069 | result.m[0][1] = m[1][0]; | - |
1070 | result.m[1][1] = m[1][1]; | - |
1071 | result.m[2][1] = m[1][2]; | - |
1072 | | - |
1073 | result.m[0][2] = m[2][0]; | - |
1074 | result.m[1][2] = m[2][1]; | - |
1075 | result.m[2][2] = m[2][2]; | - |
1076 | | - |
1077 | result.m[0][3] = 0.0f; | - |
1078 | result.m[1][3] = 0.0f; | - |
1079 | result.m[2][3] = 0.0f; | - |
1080 | | - |
1081 | result.m[3][0] = -(result.m[0][0] * m[3][0] + result.m[1][0] * m[3][1] + result.m[2][0] * m[3][2]); | - |
1082 | result.m[3][1] = -(result.m[0][1] * m[3][0] + result.m[1][1] * m[3][1] + result.m[2][1] * m[3][2]); | - |
1083 | result.m[3][2] = -(result.m[0][2] * m[3][0] + result.m[1][2] * m[3][1] + result.m[2][2] * m[3][2]); | - |
1084 | result.m[3][3] = 1.0f; | - |
1085 | | - |
1086 | result.flagBits = flagBits; | - |
1087 | | - |
1088 | return result; executed: return result; Execution Count:2 | 2 |
1089 | } | - |
1090 | void QMatrix4x4::optimize() | - |
1091 | { | - |
1092 | | - |
1093 | flagBits = General; | - |
1094 | if (m[0][3] != 0 || m[1][3] != 0 || m[2][3] != 0 || m[3][3] != 1) evaluated: m[0][3] != 0 yes Evaluation Count:5 | yes Evaluation Count:32 |
partially evaluated: m[1][3] != 0 no Evaluation Count:0 | yes Evaluation Count:32 |
partially evaluated: m[2][3] != 0 no Evaluation Count:0 | yes Evaluation Count:32 |
evaluated: m[3][3] != 1 yes Evaluation Count:3 | yes Evaluation Count:29 |
| 0-32 |
1095 | return; executed: return; Execution Count:8 | 8 |
1096 | | - |
1097 | flagBits &= ~Perspective; | - |
1098 | | - |
1099 | | - |
1100 | if (m[3][0] == 0 && m[3][1] == 0 && m[3][2] == 0) evaluated: m[3][0] == 0 yes Evaluation Count:15 | yes Evaluation Count:14 |
partially evaluated: m[3][1] == 0 yes Evaluation Count:15 | no Evaluation Count:0 |
partially evaluated: m[3][2] == 0 yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-15 |
1101 | flagBits &= ~Translation; executed: flagBits &= ~Translation; Execution Count:15 | 15 |
1102 | | - |
1103 | | - |
1104 | if (!m[0][2] && !m[1][2] && !m[2][0] && !m[2][1]) { evaluated: !m[0][2] yes Evaluation Count:27 | yes Evaluation Count:2 |
evaluated: !m[1][2] yes Evaluation Count:26 | yes Evaluation Count:1 |
partially evaluated: !m[2][0] yes Evaluation Count:26 | no Evaluation Count:0 |
partially evaluated: !m[2][1] yes Evaluation Count:26 | no Evaluation Count:0 |
| 0-27 |
1105 | flagBits &= ~Rotation; | - |
1106 | | - |
1107 | if (!m[0][1] && !m[1][0]) { evaluated: !m[0][1] yes Evaluation Count:21 | yes Evaluation Count:5 |
partially evaluated: !m[1][0] yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
1108 | flagBits &= ~Rotation2D; | - |
1109 | | - |
1110 | if (m[0][0] == 1 && m[1][1] == 1 && m[2][2] == 1) evaluated: m[0][0] == 1 yes Evaluation Count:10 | yes Evaluation Count:11 |
evaluated: m[1][1] == 1 yes Evaluation Count:9 | yes Evaluation Count:1 |
partially evaluated: m[2][2] == 1 yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-11 |
1111 | flagBits &= ~Scale; executed: flagBits &= ~Scale; Execution Count:9 | 9 |
1112 | } else { executed: } Execution Count:21 | 21 |
1113 | | - |
1114 | double mm[4][4]; | - |
1115 | copyToDoubles(m, mm); | - |
1116 | double det = matrixDet2(mm, 0, 1, 0, 1); | - |
1117 | double lenX = mm[0][0] * mm[0][0] + mm[0][1] * mm[0][1]; | - |
1118 | double lenY = mm[1][0] * mm[1][0] + mm[1][1] * mm[1][1]; | - |
1119 | double lenZ = mm[2][2]; | - |
1120 | if (qFuzzyCompare(det, 1.0) && qFuzzyCompare(lenX, 1.0) evaluated: qFuzzyCompare(det, 1.0) yes Evaluation Count:2 | yes Evaluation Count:3 |
partially evaluated: qFuzzyCompare(lenX, 1.0) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-3 |
1121 | && qFuzzyCompare(lenY, 1.0) && qFuzzyCompare(lenZ, 1.0)) partially evaluated: qFuzzyCompare(lenY, 1.0) yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: qFuzzyCompare(lenZ, 1.0) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1122 | { | - |
1123 | flagBits &= ~Scale; | - |
1124 | } executed: } Execution Count:2 | 2 |
1125 | } executed: } Execution Count:5 | 5 |
1126 | } else { | - |
1127 | | - |
1128 | double mm[4][4]; | - |
1129 | copyToDoubles(m, mm); | - |
1130 | double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2); | - |
1131 | double lenX = mm[0][0] * mm[0][0] + mm[0][1] * mm[0][1] + mm[0][2] * mm[0][2]; | - |
1132 | double lenY = mm[1][0] * mm[1][0] + mm[1][1] * mm[1][1] + mm[1][2] * mm[1][2]; | - |
1133 | double lenZ = mm[2][0] * mm[2][0] + mm[2][1] * mm[2][1] + mm[2][2] * mm[2][2]; | - |
1134 | if (qFuzzyCompare(det, 1.0) && qFuzzyCompare(lenX, 1.0) evaluated: qFuzzyCompare(det, 1.0) yes Evaluation Count:1 | yes Evaluation Count:2 |
partially evaluated: qFuzzyCompare(lenX, 1.0) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-2 |
1135 | && qFuzzyCompare(lenY, 1.0) && qFuzzyCompare(lenZ, 1.0)) partially evaluated: qFuzzyCompare(lenY, 1.0) yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: qFuzzyCompare(lenZ, 1.0) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1136 | { | - |
1137 | flagBits &= ~Scale; | - |
1138 | } executed: } Execution Count:1 | 1 |
1139 | } executed: } Execution Count:3 | 3 |
1140 | } | - |
1141 | | - |
1142 | | - |
1143 | | - |
1144 | | - |
1145 | QMatrix4x4::operator QVariant() const | - |
1146 | { | - |
1147 | return QVariant(QVariant::Matrix4x4, this); executed: return QVariant(QVariant::Matrix4x4, this); Execution Count:1 | 1 |
1148 | } | - |
1149 | | - |
1150 | | - |
1151 | | - |
1152 | QDebug operator<<(QDebug dbg, const QMatrix4x4 &m) | - |
1153 | { | - |
1154 | | - |
1155 | QByteArray bits; | - |
1156 | if (m.flagBits == QMatrix4x4::Identity) { partially evaluated: m.flagBits == QMatrix4x4::Identity yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1157 | bits = "Identity"; | - |
1158 | } else if (m.flagBits == QMatrix4x4::General) { executed: } Execution Count:1 never evaluated: m.flagBits == QMatrix4x4::General | 0-1 |
1159 | bits = "General"; | - |
1160 | } else { | 0 |
1161 | if ((m.flagBits & QMatrix4x4::Translation) != 0) never evaluated: (m.flagBits & QMatrix4x4::Translation) != 0 | 0 |
1162 | bits += "Translation,"; never executed: bits += "Translation,"; | 0 |
1163 | if ((m.flagBits & QMatrix4x4::Scale) != 0) never evaluated: (m.flagBits & QMatrix4x4::Scale) != 0 | 0 |
1164 | bits += "Scale,"; never executed: bits += "Scale,"; | 0 |
1165 | if ((m.flagBits & QMatrix4x4::Rotation2D) != 0) never evaluated: (m.flagBits & QMatrix4x4::Rotation2D) != 0 | 0 |
1166 | bits += "Rotation2D,"; never executed: bits += "Rotation2D,"; | 0 |
1167 | if ((m.flagBits & QMatrix4x4::Rotation) != 0) never evaluated: (m.flagBits & QMatrix4x4::Rotation) != 0 | 0 |
1168 | bits += "Rotation,"; never executed: bits += "Rotation,"; | 0 |
1169 | if ((m.flagBits & QMatrix4x4::Perspective) != 0) never evaluated: (m.flagBits & QMatrix4x4::Perspective) != 0 | 0 |
1170 | bits += "Perspective,"; never executed: bits += "Perspective,"; | 0 |
1171 | if (bits.size() > 0) never evaluated: bits.size() > 0 | 0 |
1172 | bits = bits.left(bits.size() - 1); never executed: bits = bits.left(bits.size() - 1); | 0 |
1173 | } | 0 |
1174 | | - |
1175 | | - |
1176 | dbg.nospace() << "QMatrix4x4(type:" << bits.constData() << endl | - |
1177 | << qSetFieldWidth(10) | - |
1178 | << m(0, 0) << m(0, 1) << m(0, 2) << m(0, 3) << endl | - |
1179 | << m(1, 0) << m(1, 1) << m(1, 2) << m(1, 3) << endl | - |
1180 | << m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << endl | - |
1181 | << m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << endl | - |
1182 | << qSetFieldWidth(0) << ')'; | - |
1183 | return dbg.space(); executed: return dbg.space(); Execution Count:1 | 1 |
1184 | } | - |
1185 | QDataStream &operator<<(QDataStream &stream, const QMatrix4x4 &matrix) | - |
1186 | { | - |
1187 | for (int row = 0; row < 4; ++row) | 0 |
1188 | for (int col = 0; col < 4; ++col) | 0 |
1189 | stream << matrix(row, col); never executed: stream << matrix(row, col); | 0 |
1190 | return stream; never executed: return stream; | 0 |
1191 | } | - |
1192 | QDataStream &operator>>(QDataStream &stream, QMatrix4x4 &matrix) | - |
1193 | { | - |
1194 | float x; | - |
1195 | for (int row = 0; row < 4; ++row) { | 0 |
1196 | for (int col = 0; col < 4; ++col) { | 0 |
1197 | stream >> x; | - |
1198 | matrix(row, col) = x; | - |
1199 | } | 0 |
1200 | } | 0 |
1201 | matrix.optimize(); | - |
1202 | return stream; never executed: return stream; | 0 |
1203 | } | - |
1204 | | - |
1205 | | - |
1206 | | - |
1207 | | - |
1208 | | - |
1209 | | - |
1210 | | - |
| | |