math3d/qmatrix4x4.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qmatrix4x4.h" -
43#include <QtCore/qmath.h> -
44#include <QtCore/qvariant.h> -
45#include <QtGui/qmatrix.h> -
46#include <QtGui/qtransform.h> -
47 -
48#include <cmath> -
49 -
50QT_BEGIN_NAMESPACE -
51 -
52#ifndef QT_NO_MATRIX4X4 -
53 -
54/*! -
55 \class QMatrix4x4 -
56 \brief The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space. -
57 \since 4.6 -
58 \ingroup painting-3D -
59 \inmodule QtGui -
60 -
61 The QMatrix4x4 class in general is treated as a row-major matrix, in that the -
62 constructors and operator() functions take data in row-major format, as is -
63 familiar in C-style usage. -
64 -
65 Internally the data is stored as column-major format, so as to be optimal for -
66 passing to OpenGL functions, which expect column-major data. -
67 -
68 When using these functions be aware that they return data in \b{column-major} -
69 format: -
70 \list -
71 \li data() -
72 \li constData() -
73 \endlist -
74 -
75 \sa QVector3D, QGenericMatrix -
76*/ -
77 -
78static const float inv_dist_to_plane = 1.0f / 1024.0f; -
79 -
80/*! -
81 \fn QMatrix4x4::QMatrix4x4() -
82 -
83 Constructs an identity matrix. -
84*/ -
85 -
86/*! -
87 Constructs a matrix from the given 16 floating-point \a values. -
88 The contents of the array \a values is assumed to be in -
89 row-major order. -
90 -
91 If the matrix has a special type (identity, translate, scale, etc), -
92 the programmer should follow this constructor with a call to -
93 optimize() if they wish QMatrix4x4 to optimize further -
94 calls to translate(), scale(), etc. -
95 -
96 \sa copyDataTo(), optimize() -
97*/ -
98QMatrix4x4::QMatrix4x4(const float *values) -
99{ -
100 for (int row = 0; row < 4; ++row)
evaluated: row < 4
TRUEFALSE
yes
Evaluation Count:476
yes
Evaluation Count:119
119-476
101 for (int col = 0; col < 4; ++col)
evaluated: col < 4
TRUEFALSE
yes
Evaluation Count:1904
yes
Evaluation Count:476
476-1904
102 m[col][row] = values[row * 4 + col];
executed: m[col][row] = values[row * 4 + col];
Execution Count:1904
1904
103 flagBits = General;
executed (the execution status of this line is deduced): flagBits = General;
-
104}
executed: }
Execution Count:119
119
105 -
106/*! -
107 \fn QMatrix4x4::QMatrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) -
108 -
109 Constructs a matrix from the 16 elements \a m11, \a m12, \a m13, \a m14, -
110 \a m21, \a m22, \a m23, \a m24, \a m31, \a m32, \a m33, \a m34, -
111 \a m41, \a m42, \a m43, and \a m44. The elements are specified in -
112 row-major order. -
113 -
114 If the matrix has a special type (identity, translate, scale, etc), -
115 the programmer should follow this constructor with a call to -
116 optimize() if they wish QMatrix4x4 to optimize further -
117 calls to translate(), scale(), etc. -
118 -
119 \sa optimize() -
120*/ -
121 -
122/*! -
123 \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, float>& matrix) -
124 -
125 Constructs a 4x4 matrix from the left-most 4 columns and top-most -
126 4 rows of \a matrix. If \a matrix has less than 4 columns or rows, -
127 the remaining elements are filled with elements from the identity -
128 matrix. -
129 -
130 \sa toGenericMatrix() -
131*/ -
132 -
133/*! -
134 \fn QGenericMatrix<N, M, float> QMatrix4x4::toGenericMatrix() const -
135 -
136 Constructs a NxM generic matrix from the left-most N columns and -
137 top-most M rows of this 4x4 matrix. If N or M is greater than 4, -
138 then the remaining elements are filled with elements from the -
139 identity matrix. -
140*/ -
141 -
142/*! -
143 \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, float>& matrix) -
144 \relates QMatrix4x4 -
145 \obsolete -
146 -
147 Returns a 4x4 matrix constructed from the left-most 4 columns and -
148 top-most 4 rows of \a matrix. If \a matrix has less than 4 columns -
149 or rows, the remaining elements are filled with elements from the -
150 identity matrix. -
151 -
152 \sa QMatrix4x4(const QGenericMatrix &) -
153*/ -
154 -
155/*! -
156 \fn QGenericMatrix<N, M, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix) -
157 \relates QMatrix4x4 -
158 \obsolete -
159 -
160 Returns a NxM generic matrix constructed from the left-most N columns -
161 and top-most M rows of \a matrix. If N or M is greater than 4, -
162 then the remaining elements are filled with elements from the -
163 identity matrix. -
164 -
165 \sa QMatrix4x4::toGenericMatrix() -
166*/ -
167 -
168/*! -
169 \internal -
170*/ -
171QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows) -
172{ -
173 for (int col = 0; col < 4; ++col) {
evaluated: col < 4
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
174 for (int row = 0; row < 4; ++row) {
evaluated: row < 4
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:4
4-16
175 if (col < cols && row < rows)
partially evaluated: col < cols
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
evaluated: row < rows
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:4
0-16
176 m[col][row] = values[col * rows + row];
executed: m[col][row] = values[col * rows + row];
Execution Count:12
12
177 else if (col == row)
evaluated: col == row
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
178 m[col][row] = 1.0f;
executed: m[col][row] = 1.0f;
Execution Count:1
1
179 else -
180 m[col][row] = 0.0f;
executed: m[col][row] = 0.0f;
Execution Count:3
3
181 } -
182 }
executed: }
Execution Count:4
4
183 flagBits = General;
executed (the execution status of this line is deduced): flagBits = General;
-
184}
executed: }
Execution Count:1
1
185 -
186/*! -
187 Constructs a 4x4 matrix from a conventional Qt 2D affine -
188 transformation \a matrix. -
189 -
190 If \a matrix has a special type (identity, translate, scale, etc), -
191 the programmer should follow this constructor with a call to -
192 optimize() if they wish QMatrix4x4 to optimize further -
193 calls to translate(), scale(), etc. -
194 -
195 \sa toAffine(), optimize() -
196*/ -
197QMatrix4x4::QMatrix4x4(const QMatrix& matrix) -
198{ -
199 m[0][0] = matrix.m11();
executed (the execution status of this line is deduced): m[0][0] = matrix.m11();
-
200 m[0][1] = matrix.m12();
executed (the execution status of this line is deduced): m[0][1] = matrix.m12();
-
201 m[0][2] = 0.0f;
executed (the execution status of this line is deduced): m[0][2] = 0.0f;
-
202 m[0][3] = 0.0f;
executed (the execution status of this line is deduced): m[0][3] = 0.0f;
-
203 m[1][0] = matrix.m21();
executed (the execution status of this line is deduced): m[1][0] = matrix.m21();
-
204 m[1][1] = matrix.m22();
executed (the execution status of this line is deduced): m[1][1] = matrix.m22();
-
205 m[1][2] = 0.0f;
executed (the execution status of this line is deduced): m[1][2] = 0.0f;
-
206 m[1][3] = 0.0f;
executed (the execution status of this line is deduced): m[1][3] = 0.0f;
-
207 m[2][0] = 0.0f;
executed (the execution status of this line is deduced): m[2][0] = 0.0f;
-
208 m[2][1] = 0.0f;
executed (the execution status of this line is deduced): m[2][1] = 0.0f;
-
209 m[2][2] = 1.0f;
executed (the execution status of this line is deduced): m[2][2] = 1.0f;
-
210 m[2][3] = 0.0f;
executed (the execution status of this line is deduced): m[2][3] = 0.0f;
-
211 m[3][0] = matrix.dx();
executed (the execution status of this line is deduced): m[3][0] = matrix.dx();
-
212 m[3][1] = matrix.dy();
executed (the execution status of this line is deduced): m[3][1] = matrix.dy();
-
213 m[3][2] = 0.0f;
executed (the execution status of this line is deduced): m[3][2] = 0.0f;
-
214 m[3][3] = 1.0f;
executed (the execution status of this line is deduced): m[3][3] = 1.0f;
-
215 flagBits = Translation | Scale | Rotation2D;
executed (the execution status of this line is deduced): flagBits = Translation | Scale | Rotation2D;
-
216}
executed: }
Execution Count:3
3
217 -
218/*! -
219 Constructs a 4x4 matrix from the conventional Qt 2D -
220 transformation matrix \a transform. -
221 -
222 If \a transform has a special type (identity, translate, scale, etc), -
223 the programmer should follow this constructor with a call to -
224 optimize() if they wish QMatrix4x4 to optimize further -
225 calls to translate(), scale(), etc. -
226 -
227 \sa toTransform(), optimize() -
228*/ -
229QMatrix4x4::QMatrix4x4(const QTransform& transform) -
230{ -
231 m[0][0] = transform.m11();
executed (the execution status of this line is deduced): m[0][0] = transform.m11();
-
232 m[0][1] = transform.m12();
executed (the execution status of this line is deduced): m[0][1] = transform.m12();
-
233 m[0][2] = 0.0f;
executed (the execution status of this line is deduced): m[0][2] = 0.0f;
-
234 m[0][3] = transform.m13();
executed (the execution status of this line is deduced): m[0][3] = transform.m13();
-
235 m[1][0] = transform.m21();
executed (the execution status of this line is deduced): m[1][0] = transform.m21();
-
236 m[1][1] = transform.m22();
executed (the execution status of this line is deduced): m[1][1] = transform.m22();
-
237 m[1][2] = 0.0f;
executed (the execution status of this line is deduced): m[1][2] = 0.0f;
-
238 m[1][3] = transform.m23();
executed (the execution status of this line is deduced): m[1][3] = transform.m23();
-
239 m[2][0] = 0.0f;
executed (the execution status of this line is deduced): m[2][0] = 0.0f;
-
240 m[2][1] = 0.0f;
executed (the execution status of this line is deduced): m[2][1] = 0.0f;
-
241 m[2][2] = 1.0f;
executed (the execution status of this line is deduced): m[2][2] = 1.0f;
-
242 m[2][3] = 0.0f;
executed (the execution status of this line is deduced): m[2][3] = 0.0f;
-
243 m[3][0] = transform.dx();
executed (the execution status of this line is deduced): m[3][0] = transform.dx();
-
244 m[3][1] = transform.dy();
executed (the execution status of this line is deduced): m[3][1] = transform.dy();
-
245 m[3][2] = 0.0f;
executed (the execution status of this line is deduced): m[3][2] = 0.0f;
-
246 m[3][3] = transform.m33();
executed (the execution status of this line is deduced): m[3][3] = transform.m33();
-
247 flagBits = General;
executed (the execution status of this line is deduced): flagBits = General;
-
248}
executed: }
Execution Count:2891
2891
249 -
250/*! -
251 \fn const float& QMatrix4x4::operator()(int row, int column) const -
252 -
253 Returns a constant reference to the element at position -
254 (\a row, \a column) in this matrix. -
255 -
256 \sa column(), row() -
257*/ -
258 -
259/*! -
260 \fn float& QMatrix4x4::operator()(int row, int column) -
261 -
262 Returns a reference to the element at position (\a row, \a column) -
263 in this matrix so that the element can be assigned to. -
264 -
265 \sa optimize(), setColumn(), setRow() -
266*/ -
267 -
268/*! -
269 \fn QVector4D QMatrix4x4::column(int index) const -
270 -
271 Returns the elements of column \a index as a 4D vector. -
272 -
273 \sa setColumn(), row() -
274*/ -
275 -
276/*! -
277 \fn void QMatrix4x4::setColumn(int index, const QVector4D& value) -
278 -
279 Sets the elements of column \a index to the components of \a value. -
280 -
281 \sa column(), setRow() -
282*/ -
283 -
284/*! -
285 \fn QVector4D QMatrix4x4::row(int index) const -
286 -
287 Returns the elements of row \a index as a 4D vector. -
288 -
289 \sa setRow(), column() -
290*/ -
291 -
292/*! -
293 \fn void QMatrix4x4::setRow(int index, const QVector4D& value) -
294 -
295 Sets the elements of row \a index to the components of \a value. -
296 -
297 \sa row(), setColumn() -
298*/ -
299 -
300/*! -
301 \fn bool QMatrix4x4::isIdentity() const -
302 -
303 Returns true if this matrix is the identity; false otherwise. -
304 -
305 \sa setToIdentity() -
306*/ -
307 -
308/*! -
309 \fn void QMatrix4x4::setToIdentity() -
310 -
311 Sets this matrix to the identity. -
312 -
313 \sa isIdentity() -
314*/ -
315 -
316/*! -
317 \fn void QMatrix4x4::fill(float value) -
318 -
319 Fills all elements of this matrx with \a value. -
320*/ -
321 -
322static inline double matrixDet2(const double m[4][4], int col0, int col1, int row0, int row1) -
323{ -
324 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
325} -
326 -
327 -
328// The 4x4 matrix inverse algorithm is based on that described at: -
329// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q24 -
330// Some optimization has been done to avoid making copies of 3x3 -
331// sub-matrices and to unroll the loops. -
332 -
333// Calculate the determinant of a 3x3 sub-matrix. -
334// | A B C | -
335// M = | D E F | det(M) = A * (EI - HF) - B * (DI - GF) + C * (DH - GE) -
336// | G H I | -
337static inline double matrixDet3 -
338 (const double m[4][4], int col0, int col1, int col2, -
339 int row0, int row1, int row2) -
340{ -
341 return m[col0][row0] * matrixDet2(m, col1, col2, 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
342 - m[col1][row0] * matrixDet2(m, col0, col2, 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
343 + 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
344} -
345 -
346// Calculate the determinant of a 4x4 matrix. -
347static inline double matrixDet4(const double m[4][4]) -
348{ -
349 double det;
executed (the execution status of this line is deduced): double det;
-
350 det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
executed (the execution status of this line is deduced): det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
-
351 det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
executed (the execution status of this line is deduced): det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
-
352 det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
executed (the execution status of this line is deduced): det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
-
353 det -= m[3][0] * matrixDet3(m, 0, 1, 2, 1, 2, 3);
executed (the execution status of this line is deduced): det -= m[3][0] * matrixDet3(m, 0, 1, 2, 1, 2, 3);
-
354 return det;
executed: return det;
Execution Count:23
23
355} -
356 -
357static inline void copyToDoubles(const float m[4][4], double mm[4][4]) -
358{ -
359 for (int i = 0; i < 4; ++i)
evaluated: i < 4
TRUEFALSE
yes
Evaluation Count:168
yes
Evaluation Count:42
42-168
360 for (int j = 0; j < 4; ++j)
evaluated: j < 4
TRUEFALSE
yes
Evaluation Count:672
yes
Evaluation Count:168
168-672
361 mm[i][j] = double(m[i][j]);
executed: mm[i][j] = double(m[i][j]);
Execution Count:672
672
362}
executed: }
Execution Count:42
42
363 -
364/*! -
365 Returns the determinant of this matrix. -
366*/ -
367double QMatrix4x4::determinant() const -
368{ -
369 if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity)
partially evaluated: (flagBits & ~(Translation | Rotation2D | Rotation)) == Identity
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
370 return 1.0;
never executed: return 1.0;
0
371 -
372 double mm[4][4];
executed (the execution status of this line is deduced): double mm[4][4];
-
373 copyToDoubles(m, mm);
executed (the execution status of this line is deduced): copyToDoubles(m, mm);
-
374 if (flagBits < Rotation2D)
partially evaluated: flagBits < Rotation2D
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
375 return mm[0][0] * mm[1][1] * mm[2][2]; // Translation | Scale
never executed: return mm[0][0] * mm[1][1] * mm[2][2];
0
376 if (flagBits < Perspective)
partially evaluated: flagBits < Perspective
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
377 return matrixDet3(mm, 0, 1, 2, 0, 1, 2);
never executed: return matrixDet3(mm, 0, 1, 2, 0, 1, 2);
0
378 return matrixDet4(mm);
executed: return matrixDet4(mm);
Execution Count:12
12
379} -
380 -
381/*! -
382 Returns the inverse of this matrix. Returns the identity if -
383 this matrix cannot be inverted; i.e. determinant() is zero. -
384 If \a invertible is not null, then true will be written to -
385 that location if the matrix can be inverted; false otherwise. -
386 -
387 If the matrix is recognized as the identity or an orthonormal -
388 matrix, then this function will quickly invert the matrix -
389 using optimized routines. -
390 -
391 \sa determinant(), normalMatrix() -
392*/ -
393QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const -
394{ -
395 // Handle some of the easy cases first. -
396 if (flagBits == Identity) {
evaluated: flagBits == Identity
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:16
3-16
397 if (invertible)
evaluated: invertible
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
398 *invertible = true;
executed: *invertible = true;
Execution Count:1
1
399 return QMatrix4x4();
executed: return QMatrix4x4();
Execution Count:3
3
400 } else if (flagBits == Translation) {
evaluated: flagBits == Translation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-15
401 QMatrix4x4 inv;
executed (the execution status of this line is deduced): QMatrix4x4 inv;
-
402 inv.m[3][0] = -m[3][0];
executed (the execution status of this line is deduced): inv.m[3][0] = -m[3][0];
-
403 inv.m[3][1] = -m[3][1];
executed (the execution status of this line is deduced): inv.m[3][1] = -m[3][1];
-
404 inv.m[3][2] = -m[3][2];
executed (the execution status of this line is deduced): inv.m[3][2] = -m[3][2];
-
405 inv.flagBits = Translation;
executed (the execution status of this line is deduced): inv.flagBits = Translation;
-
406 if (invertible)
partially evaluated: invertible
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
407 *invertible = true;
executed: *invertible = true;
Execution Count:1
1
408 return inv;
executed: return inv;
Execution Count:1
1
409 } else if (flagBits < Rotation2D) {
evaluated: flagBits < Rotation2D
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14
1-14
410 // Translation | Scale -
411 if (m[0][0] == 0 || m[1][1] == 0 || m[2][2] == 0) {
partially evaluated: m[0][0] == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: m[1][1] == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: m[2][2] == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
412 if (invertible)
never evaluated: invertible
0
413 *invertible = false;
never executed: *invertible = false;
0
414 return QMatrix4x4();
never executed: return QMatrix4x4();
0
415 } -
416 QMatrix4x4 inv;
executed (the execution status of this line is deduced): QMatrix4x4 inv;
-
417 inv.m[0][0] = 1.0f / m[0][0];
executed (the execution status of this line is deduced): inv.m[0][0] = 1.0f / m[0][0];
-
418 inv.m[1][1] = 1.0f / m[1][1];
executed (the execution status of this line is deduced): inv.m[1][1] = 1.0f / m[1][1];
-
419 inv.m[2][2] = 1.0f / m[2][2];
executed (the execution status of this line is deduced): inv.m[2][2] = 1.0f / m[2][2];
-
420 inv.m[3][0] = -m[3][0] * inv.m[0][0];
executed (the execution status of this line is deduced): inv.m[3][0] = -m[3][0] * inv.m[0][0];
-
421 inv.m[3][1] = -m[3][1] * inv.m[1][1];
executed (the execution status of this line is deduced): inv.m[3][1] = -m[3][1] * inv.m[1][1];
-
422 inv.m[3][2] = -m[3][2] * inv.m[2][2];
executed (the execution status of this line is deduced): inv.m[3][2] = -m[3][2] * inv.m[2][2];
-
423 inv.flagBits = flagBits;
executed (the execution status of this line is deduced): inv.flagBits = flagBits;
-
424 -
425 if (invertible)
partially evaluated: invertible
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
426 *invertible = true;
executed: *invertible = true;
Execution Count:1
1
427 return inv;
executed: return inv;
Execution Count:1
1
428 } else if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity) {
evaluated: (flagBits & ~(Translation | Rotation2D | Rotation)) == Identity
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:12
2-12
429 if (invertible)
evaluated: invertible
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
430 *invertible = true;
executed: *invertible = true;
Execution Count:1
1
431 return orthonormalInverse();
executed: return orthonormalInverse();
Execution Count:2
2
432 } else if (flagBits < Perspective) {
evaluated: flagBits < Perspective
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
1-11
433 QMatrix4x4 inv(1); // The "1" says to not load the identity.
executed (the execution status of this line is deduced): QMatrix4x4 inv(1);
-
434 -
435 double mm[4][4];
executed (the execution status of this line is deduced): double mm[4][4];
-
436 copyToDoubles(m, mm);
executed (the execution status of this line is deduced): copyToDoubles(m, mm);
-
437 -
438 double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);
executed (the execution status of this line is deduced): double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);
-
439 if (det == 0.0f) {
partially evaluated: det == 0.0f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
440 if (invertible)
never evaluated: invertible
0
441 *invertible = false;
never executed: *invertible = false;
0
442 return QMatrix4x4();
never executed: return QMatrix4x4();
0
443 } -
444 det = 1.0f / det;
executed (the execution status of this line is deduced): det = 1.0f / det;
-
445 -
446 inv.m[0][0] = matrixDet2(mm, 1, 2, 1, 2) * det;
executed (the execution status of this line is deduced): inv.m[0][0] = matrixDet2(mm, 1, 2, 1, 2) * det;
-
447 inv.m[0][1] = -matrixDet2(mm, 0, 2, 1, 2) * det;
executed (the execution status of this line is deduced): inv.m[0][1] = -matrixDet2(mm, 0, 2, 1, 2) * det;
-
448 inv.m[0][2] = matrixDet2(mm, 0, 1, 1, 2) * det;
executed (the execution status of this line is deduced): inv.m[0][2] = matrixDet2(mm, 0, 1, 1, 2) * det;
-
449 inv.m[0][3] = 0;
executed (the execution status of this line is deduced): inv.m[0][3] = 0;
-
450 inv.m[1][0] = -matrixDet2(mm, 1, 2, 0, 2) * det;
executed (the execution status of this line is deduced): inv.m[1][0] = -matrixDet2(mm, 1, 2, 0, 2) * det;
-
451 inv.m[1][1] = matrixDet2(mm, 0, 2, 0, 2) * det;
executed (the execution status of this line is deduced): inv.m[1][1] = matrixDet2(mm, 0, 2, 0, 2) * det;
-
452 inv.m[1][2] = -matrixDet2(mm, 0, 1, 0, 2) * det;
executed (the execution status of this line is deduced): inv.m[1][2] = -matrixDet2(mm, 0, 1, 0, 2) * det;
-
453 inv.m[1][3] = 0;
executed (the execution status of this line is deduced): inv.m[1][3] = 0;
-
454 inv.m[2][0] = matrixDet2(mm, 1, 2, 0, 1) * det;
executed (the execution status of this line is deduced): inv.m[2][0] = matrixDet2(mm, 1, 2, 0, 1) * det;
-
455 inv.m[2][1] = -matrixDet2(mm, 0, 2, 0, 1) * det;
executed (the execution status of this line is deduced): inv.m[2][1] = -matrixDet2(mm, 0, 2, 0, 1) * det;
-
456 inv.m[2][2] = matrixDet2(mm, 0, 1, 0, 1) * det;
executed (the execution status of this line is deduced): inv.m[2][2] = matrixDet2(mm, 0, 1, 0, 1) * det;
-
457 inv.m[2][3] = 0;
executed (the execution status of this line is deduced): inv.m[2][3] = 0;
-
458 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];
executed (the execution status of this line is deduced): 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];
-
459 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];
executed (the execution status of this line is deduced): 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];
-
460 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];
executed (the execution status of this line is deduced): 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];
-
461 inv.m[3][3] = 1;
executed (the execution status of this line is deduced): inv.m[3][3] = 1;
-
462 inv.flagBits = flagBits;
executed (the execution status of this line is deduced): inv.flagBits = flagBits;
-
463 -
464 if (invertible)
partially evaluated: invertible
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
465 *invertible = true;
executed: *invertible = true;
Execution Count:1
1
466 return inv;
executed: return inv;
Execution Count:1
1
467 } -
468 -
469 QMatrix4x4 inv(1); // The "1" says to not load the identity.
executed (the execution status of this line is deduced): QMatrix4x4 inv(1);
-
470 -
471 double mm[4][4];
executed (the execution status of this line is deduced): double mm[4][4];
-
472 copyToDoubles(m, mm);
executed (the execution status of this line is deduced): copyToDoubles(m, mm);
-
473 -
474 double det = matrixDet4(mm);
executed (the execution status of this line is deduced): double det = matrixDet4(mm);
-
475 if (det == 0.0f) {
evaluated: det == 0.0f
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:7
4-7
476 if (invertible)
partially evaluated: invertible
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
477 *invertible = false;
executed: *invertible = false;
Execution Count:4
4
478 return QMatrix4x4();
executed: return QMatrix4x4();
Execution Count:4
4
479 } -
480 det = 1.0f / det;
executed (the execution status of this line is deduced): det = 1.0f / det;
-
481 -
482 inv.m[0][0] = matrixDet3(mm, 1, 2, 3, 1, 2, 3) * det;
executed (the execution status of this line is deduced): inv.m[0][0] = matrixDet3(mm, 1, 2, 3, 1, 2, 3) * det;
-
483 inv.m[0][1] = -matrixDet3(mm, 0, 2, 3, 1, 2, 3) * det;
executed (the execution status of this line is deduced): inv.m[0][1] = -matrixDet3(mm, 0, 2, 3, 1, 2, 3) * det;
-
484 inv.m[0][2] = matrixDet3(mm, 0, 1, 3, 1, 2, 3) * det;
executed (the execution status of this line is deduced): inv.m[0][2] = matrixDet3(mm, 0, 1, 3, 1, 2, 3) * det;
-
485 inv.m[0][3] = -matrixDet3(mm, 0, 1, 2, 1, 2, 3) * det;
executed (the execution status of this line is deduced): inv.m[0][3] = -matrixDet3(mm, 0, 1, 2, 1, 2, 3) * det;
-
486 inv.m[1][0] = -matrixDet3(mm, 1, 2, 3, 0, 2, 3) * det;
executed (the execution status of this line is deduced): inv.m[1][0] = -matrixDet3(mm, 1, 2, 3, 0, 2, 3) * det;
-
487 inv.m[1][1] = matrixDet3(mm, 0, 2, 3, 0, 2, 3) * det;
executed (the execution status of this line is deduced): inv.m[1][1] = matrixDet3(mm, 0, 2, 3, 0, 2, 3) * det;
-
488 inv.m[1][2] = -matrixDet3(mm, 0, 1, 3, 0, 2, 3) * det;
executed (the execution status of this line is deduced): inv.m[1][2] = -matrixDet3(mm, 0, 1, 3, 0, 2, 3) * det;
-
489 inv.m[1][3] = matrixDet3(mm, 0, 1, 2, 0, 2, 3) * det;
executed (the execution status of this line is deduced): inv.m[1][3] = matrixDet3(mm, 0, 1, 2, 0, 2, 3) * det;
-
490 inv.m[2][0] = matrixDet3(mm, 1, 2, 3, 0, 1, 3) * det;
executed (the execution status of this line is deduced): inv.m[2][0] = matrixDet3(mm, 1, 2, 3, 0, 1, 3) * det;
-
491 inv.m[2][1] = -matrixDet3(mm, 0, 2, 3, 0, 1, 3) * det;
executed (the execution status of this line is deduced): inv.m[2][1] = -matrixDet3(mm, 0, 2, 3, 0, 1, 3) * det;
-
492 inv.m[2][2] = matrixDet3(mm, 0, 1, 3, 0, 1, 3) * det;
executed (the execution status of this line is deduced): inv.m[2][2] = matrixDet3(mm, 0, 1, 3, 0, 1, 3) * det;
-
493 inv.m[2][3] = -matrixDet3(mm, 0, 1, 2, 0, 1, 3) * det;
executed (the execution status of this line is deduced): inv.m[2][3] = -matrixDet3(mm, 0, 1, 2, 0, 1, 3) * det;
-
494 inv.m[3][0] = -matrixDet3(mm, 1, 2, 3, 0, 1, 2) * det;
executed (the execution status of this line is deduced): inv.m[3][0] = -matrixDet3(mm, 1, 2, 3, 0, 1, 2) * det;
-
495 inv.m[3][1] = matrixDet3(mm, 0, 2, 3, 0, 1, 2) * det;
executed (the execution status of this line is deduced): inv.m[3][1] = matrixDet3(mm, 0, 2, 3, 0, 1, 2) * det;
-
496 inv.m[3][2] = -matrixDet3(mm, 0, 1, 3, 0, 1, 2) * det;
executed (the execution status of this line is deduced): inv.m[3][2] = -matrixDet3(mm, 0, 1, 3, 0, 1, 2) * det;
-
497 inv.m[3][3] = matrixDet3(mm, 0, 1, 2, 0, 1, 2) * det;
executed (the execution status of this line is deduced): inv.m[3][3] = matrixDet3(mm, 0, 1, 2, 0, 1, 2) * det;
-
498 inv.flagBits = flagBits;
executed (the execution status of this line is deduced): inv.flagBits = flagBits;
-
499 -
500 if (invertible)
evaluated: invertible
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3
3-4
501 *invertible = true;
executed: *invertible = true;
Execution Count:4
4
502 return inv;
executed: return inv;
Execution Count:7
7
503} -
504 -
505/*! -
506 Returns the normal matrix corresponding to this 4x4 transformation. -
507 The normal matrix is the transpose of the inverse of the top-left -
508 3x3 part of this 4x4 matrix. If the 3x3 sub-matrix is not invertible, -
509 this function returns the identity. -
510 -
511 \sa inverted() -
512*/ -
513QMatrix3x3 QMatrix4x4::normalMatrix() const -
514{ -
515 QMatrix3x3 inv;
executed (the execution status of this line is deduced): QMatrix3x3 inv;
-
516 -
517 // Handle the simple cases first. -
518 if (flagBits < Scale) {
evaluated: flagBits < Scale
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:16
2-16
519 // Translation -
520 return inv;
executed: return inv;
Execution Count:2
2
521 } else if (flagBits < Rotation2D) {
evaluated: flagBits < Rotation2D
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:11
5-11
522 // Translation | Scale -
523 if (m[0][0] == 0.0f || m[1][1] == 0.0f || m[2][2] == 0.0f)
evaluated: m[0][0] == 0.0f
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
evaluated: m[1][1] == 0.0f
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
evaluated: m[2][2] == 0.0f
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-4
524 return inv;
executed: return inv;
Execution Count:3
3
525 inv.data()[0] = 1.0f / m[0][0];
executed (the execution status of this line is deduced): inv.data()[0] = 1.0f / m[0][0];
-
526 inv.data()[4] = 1.0f / m[1][1];
executed (the execution status of this line is deduced): inv.data()[4] = 1.0f / m[1][1];
-
527 inv.data()[8] = 1.0f / m[2][2];
executed (the execution status of this line is deduced): inv.data()[8] = 1.0f / m[2][2];
-
528 return inv;
executed: return inv;
Execution Count:2
2
529 } else if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity) {
evaluated: (flagBits & ~(Translation | Rotation2D | Rotation)) == Identity
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:10
1-10
530 float *invm = inv.data();
executed (the execution status of this line is deduced): float *invm = inv.data();
-
531 invm[0 + 0 * 3] = m[0][0];
executed (the execution status of this line is deduced): invm[0 + 0 * 3] = m[0][0];
-
532 invm[1 + 0 * 3] = m[0][1];
executed (the execution status of this line is deduced): invm[1 + 0 * 3] = m[0][1];
-
533 invm[2 + 0 * 3] = m[0][2];
executed (the execution status of this line is deduced): invm[2 + 0 * 3] = m[0][2];
-
534 invm[0 + 1 * 3] = m[1][0];
executed (the execution status of this line is deduced): invm[0 + 1 * 3] = m[1][0];
-
535 invm[1 + 1 * 3] = m[1][1];
executed (the execution status of this line is deduced): invm[1 + 1 * 3] = m[1][1];
-
536 invm[2 + 1 * 3] = m[1][2];
executed (the execution status of this line is deduced): invm[2 + 1 * 3] = m[1][2];
-
537 invm[0 + 2 * 3] = m[2][0];
executed (the execution status of this line is deduced): invm[0 + 2 * 3] = m[2][0];
-
538 invm[1 + 2 * 3] = m[2][1];
executed (the execution status of this line is deduced): invm[1 + 2 * 3] = m[2][1];
-
539 invm[2 + 2 * 3] = m[2][2];
executed (the execution status of this line is deduced): invm[2 + 2 * 3] = m[2][2];
-
540 return inv;
executed: return inv;
Execution Count:1
1
541 } -
542 -
543 double mm[4][4];
executed (the execution status of this line is deduced): double mm[4][4];
-
544 copyToDoubles(m, mm);
executed (the execution status of this line is deduced): copyToDoubles(m, mm);
-
545 double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);
executed (the execution status of this line is deduced): double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);
-
546 if (det == 0.0f)
evaluated: det == 0.0f
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
547 return inv;
executed: return inv;
Execution Count:5
5
548 det = 1.0f / det;
executed (the execution status of this line is deduced): det = 1.0f / det;
-
549 -
550 float *invm = inv.data();
executed (the execution status of this line is deduced): float *invm = inv.data();
-
551 -
552 // Invert and transpose in a single step. -
553 invm[0 + 0 * 3] = (mm[1][1] * mm[2][2] - mm[2][1] * mm[1][2]) * det;
executed (the execution status of this line is deduced): invm[0 + 0 * 3] = (mm[1][1] * mm[2][2] - mm[2][1] * mm[1][2]) * det;
-
554 invm[1 + 0 * 3] = -(mm[1][0] * mm[2][2] - mm[1][2] * mm[2][0]) * det;
executed (the execution status of this line is deduced): invm[1 + 0 * 3] = -(mm[1][0] * mm[2][2] - mm[1][2] * mm[2][0]) * det;
-
555 invm[2 + 0 * 3] = (mm[1][0] * mm[2][1] - mm[1][1] * mm[2][0]) * det;
executed (the execution status of this line is deduced): invm[2 + 0 * 3] = (mm[1][0] * mm[2][1] - mm[1][1] * mm[2][0]) * det;
-
556 invm[0 + 1 * 3] = -(mm[0][1] * mm[2][2] - mm[2][1] * mm[0][2]) * det;
executed (the execution status of this line is deduced): invm[0 + 1 * 3] = -(mm[0][1] * mm[2][2] - mm[2][1] * mm[0][2]) * det;
-
557 invm[1 + 1 * 3] = (mm[0][0] * mm[2][2] - mm[0][2] * mm[2][0]) * det;
executed (the execution status of this line is deduced): invm[1 + 1 * 3] = (mm[0][0] * mm[2][2] - mm[0][2] * mm[2][0]) * det;
-
558 invm[2 + 1 * 3] = -(mm[0][0] * mm[2][1] - mm[0][1] * mm[2][0]) * det;
executed (the execution status of this line is deduced): invm[2 + 1 * 3] = -(mm[0][0] * mm[2][1] - mm[0][1] * mm[2][0]) * det;
-
559 invm[0 + 2 * 3] = (mm[0][1] * mm[1][2] - mm[0][2] * mm[1][1]) * det;
executed (the execution status of this line is deduced): invm[0 + 2 * 3] = (mm[0][1] * mm[1][2] - mm[0][2] * mm[1][1]) * det;
-
560 invm[1 + 2 * 3] = -(mm[0][0] * mm[1][2] - mm[0][2] * mm[1][0]) * det;
executed (the execution status of this line is deduced): invm[1 + 2 * 3] = -(mm[0][0] * mm[1][2] - mm[0][2] * mm[1][0]) * det;
-
561 invm[2 + 2 * 3] = (mm[0][0] * mm[1][1] - mm[1][0] * mm[0][1]) * det;
executed (the execution status of this line is deduced): invm[2 + 2 * 3] = (mm[0][0] * mm[1][1] - mm[1][0] * mm[0][1]) * det;
-
562 -
563 return inv;
executed: return inv;
Execution Count:5
5
564} -
565 -
566/*! -
567 Returns this matrix, transposed about its diagonal. -
568*/ -
569QMatrix4x4 QMatrix4x4::transposed() const -
570{ -
571 QMatrix4x4 result(1); // The "1" says to not load the identity.
executed (the execution status of this line is deduced): QMatrix4x4 result(1);
-
572 for (int row = 0; row < 4; ++row) {
evaluated: row < 4
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:3
3-12
573 for (int col = 0; col < 4; ++col) {
evaluated: col < 4
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:12
12-48
574 result.m[col][row] = m[row][col];
executed (the execution status of this line is deduced): result.m[col][row] = m[row][col];
-
575 }
executed: }
Execution Count:48
48
576 }
executed: }
Execution Count:12
12
577 // When a translation is transposed, it becomes a perspective transformation. -
578 result.flagBits = (flagBits & Translation ? General : flagBits);
evaluated: flagBits & Translation
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
579 return result;
executed: return result;
Execution Count:3
3
580} -
581 -
582/*! -
583 \fn QMatrix4x4& QMatrix4x4::operator+=(const QMatrix4x4& other) -
584 -
585 Adds the contents of \a other to this matrix. -
586*/ -
587 -
588/*! -
589 \fn QMatrix4x4& QMatrix4x4::operator-=(const QMatrix4x4& other) -
590 -
591 Subtracts the contents of \a other from this matrix. -
592*/ -
593 -
594/*! -
595 \fn QMatrix4x4& QMatrix4x4::operator*=(const QMatrix4x4& other) -
596 -
597 Multiplies the contents of \a other by this matrix. -
598*/ -
599 -
600/*! -
601 \fn QMatrix4x4& QMatrix4x4::operator*=(float factor) -
602 \overload -
603 -
604 Multiplies all elements of this matrix by \a factor. -
605*/ -
606 -
607/*! -
608 \overload -
609 -
610 Divides all elements of this matrix by \a divisor. -
611*/ -
612QMatrix4x4& QMatrix4x4::operator/=(float divisor) -
613{ -
614 m[0][0] /= divisor;
executed (the execution status of this line is deduced): m[0][0] /= divisor;
-
615 m[0][1] /= divisor;
executed (the execution status of this line is deduced): m[0][1] /= divisor;
-
616 m[0][2] /= divisor;
executed (the execution status of this line is deduced): m[0][2] /= divisor;
-
617 m[0][3] /= divisor;
executed (the execution status of this line is deduced): m[0][3] /= divisor;
-
618 m[1][0] /= divisor;
executed (the execution status of this line is deduced): m[1][0] /= divisor;
-
619 m[1][1] /= divisor;
executed (the execution status of this line is deduced): m[1][1] /= divisor;
-
620 m[1][2] /= divisor;
executed (the execution status of this line is deduced): m[1][2] /= divisor;
-
621 m[1][3] /= divisor;
executed (the execution status of this line is deduced): m[1][3] /= divisor;
-
622 m[2][0] /= divisor;
executed (the execution status of this line is deduced): m[2][0] /= divisor;
-
623 m[2][1] /= divisor;
executed (the execution status of this line is deduced): m[2][1] /= divisor;
-
624 m[2][2] /= divisor;
executed (the execution status of this line is deduced): m[2][2] /= divisor;
-
625 m[2][3] /= divisor;
executed (the execution status of this line is deduced): m[2][3] /= divisor;
-
626 m[3][0] /= divisor;
executed (the execution status of this line is deduced): m[3][0] /= divisor;
-
627 m[3][1] /= divisor;
executed (the execution status of this line is deduced): m[3][1] /= divisor;
-
628 m[3][2] /= divisor;
executed (the execution status of this line is deduced): m[3][2] /= divisor;
-
629 m[3][3] /= divisor;
executed (the execution status of this line is deduced): m[3][3] /= divisor;
-
630 flagBits = General;
executed (the execution status of this line is deduced): flagBits = General;
-
631 return *this;
executed: return *this;
Execution Count:4
4
632} -
633 -
634/*! -
635 \fn bool QMatrix4x4::operator==(const QMatrix4x4& other) const -
636 -
637 Returns true if this matrix is identical to \a other; false otherwise. -
638 This operator uses an exact floating-point comparison. -
639*/ -
640 -
641/*! -
642 \fn bool QMatrix4x4::operator!=(const QMatrix4x4& other) const -
643 -
644 Returns true if this matrix is not identical to \a other; false otherwise. -
645 This operator uses an exact floating-point comparison. -
646*/ -
647 -
648/*! -
649 \fn QMatrix4x4 operator+(const QMatrix4x4& m1, const QMatrix4x4& m2) -
650 \relates QMatrix4x4 -
651 -
652 Returns the sum of \a m1 and \a m2. -
653*/ -
654 -
655/*! -
656 \fn QMatrix4x4 operator-(const QMatrix4x4& m1, const QMatrix4x4& m2) -
657 \relates QMatrix4x4 -
658 -
659 Returns the difference of \a m1 and \a m2. -
660*/ -
661 -
662/*! -
663 \fn QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2) -
664 \relates QMatrix4x4 -
665 -
666 Returns the product of \a m1 and \a m2. -
667*/ -
668 -
669#ifndef QT_NO_VECTOR3D -
670 -
671/*! -
672 \fn QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix) -
673 \relates QMatrix4x4 -
674 -
675 Returns the result of transforming \a vector according to \a matrix, -
676 with the matrix applied post-vector. -
677*/ -
678 -
679/*! -
680 \fn QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector) -
681 \relates QMatrix4x4 -
682 -
683 Returns the result of transforming \a vector according to \a matrix, -
684 with the matrix applied pre-vector. -
685*/ -
686 -
687#endif -
688 -
689#ifndef QT_NO_VECTOR4D -
690 -
691/*! -
692 \fn QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix) -
693 \relates QMatrix4x4 -
694 -
695 Returns the result of transforming \a vector according to \a matrix, -
696 with the matrix applied post-vector. -
697*/ -
698 -
699/*! -
700 \fn QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector) -
701 \relates QMatrix4x4 -
702 -
703 Returns the result of transforming \a vector according to \a matrix, -
704 with the matrix applied pre-vector. -
705*/ -
706 -
707#endif -
708 -
709/*! -
710 \fn QPoint operator*(const QPoint& point, const QMatrix4x4& matrix) -
711 \relates QMatrix4x4 -
712 -
713 Returns the result of transforming \a point according to \a matrix, -
714 with the matrix applied post-point. -
715*/ -
716 -
717/*! -
718 \fn QPointF operator*(const QPointF& point, const QMatrix4x4& matrix) -
719 \relates QMatrix4x4 -
720 -
721 Returns the result of transforming \a point according to \a matrix, -
722 with the matrix applied post-point. -
723*/ -
724 -
725/*! -
726 \fn QPoint operator*(const QMatrix4x4& matrix, const QPoint& point) -
727 \relates QMatrix4x4 -
728 -
729 Returns the result of transforming \a point according to \a matrix, -
730 with the matrix applied pre-point. -
731*/ -
732 -
733/*! -
734 \fn QPointF operator*(const QMatrix4x4& matrix, const QPointF& point) -
735 \relates QMatrix4x4 -
736 -
737 Returns the result of transforming \a point according to \a matrix, -
738 with the matrix applied pre-point. -
739*/ -
740 -
741/*! -
742 \fn QMatrix4x4 operator-(const QMatrix4x4& matrix) -
743 \overload -
744 \relates QMatrix4x4 -
745 -
746 Returns the negation of \a matrix. -
747*/ -
748 -
749/*! -
750 \fn QMatrix4x4 operator*(float factor, const QMatrix4x4& matrix) -
751 \relates QMatrix4x4 -
752 -
753 Returns the result of multiplying all elements of \a matrix by \a factor. -
754*/ -
755 -
756/*! -
757 \fn QMatrix4x4 operator*(const QMatrix4x4& matrix, float factor) -
758 \relates QMatrix4x4 -
759 -
760 Returns the result of multiplying all elements of \a matrix by \a factor. -
761*/ -
762 -
763/*! -
764 \relates QMatrix4x4 -
765 -
766 Returns the result of dividing all elements of \a matrix by \a divisor. -
767*/ -
768QMatrix4x4 operator/(const QMatrix4x4& matrix, float divisor) -
769{ -
770 QMatrix4x4 m(1); // The "1" says to not load the identity.
executed (the execution status of this line is deduced): QMatrix4x4 m(1);
-
771 m.m[0][0] = matrix.m[0][0] / divisor;
executed (the execution status of this line is deduced): m.m[0][0] = matrix.m[0][0] / divisor;
-
772 m.m[0][1] = matrix.m[0][1] / divisor;
executed (the execution status of this line is deduced): m.m[0][1] = matrix.m[0][1] / divisor;
-
773 m.m[0][2] = matrix.m[0][2] / divisor;
executed (the execution status of this line is deduced): m.m[0][2] = matrix.m[0][2] / divisor;
-
774 m.m[0][3] = matrix.m[0][3] / divisor;
executed (the execution status of this line is deduced): m.m[0][3] = matrix.m[0][3] / divisor;
-
775 m.m[1][0] = matrix.m[1][0] / divisor;
executed (the execution status of this line is deduced): m.m[1][0] = matrix.m[1][0] / divisor;
-
776 m.m[1][1] = matrix.m[1][1] / divisor;
executed (the execution status of this line is deduced): m.m[1][1] = matrix.m[1][1] / divisor;
-
777 m.m[1][2] = matrix.m[1][2] / divisor;
executed (the execution status of this line is deduced): m.m[1][2] = matrix.m[1][2] / divisor;
-
778 m.m[1][3] = matrix.m[1][3] / divisor;
executed (the execution status of this line is deduced): m.m[1][3] = matrix.m[1][3] / divisor;
-
779 m.m[2][0] = matrix.m[2][0] / divisor;
executed (the execution status of this line is deduced): m.m[2][0] = matrix.m[2][0] / divisor;
-
780 m.m[2][1] = matrix.m[2][1] / divisor;
executed (the execution status of this line is deduced): m.m[2][1] = matrix.m[2][1] / divisor;
-
781 m.m[2][2] = matrix.m[2][2] / divisor;
executed (the execution status of this line is deduced): m.m[2][2] = matrix.m[2][2] / divisor;
-
782 m.m[2][3] = matrix.m[2][3] / divisor;
executed (the execution status of this line is deduced): m.m[2][3] = matrix.m[2][3] / divisor;
-
783 m.m[3][0] = matrix.m[3][0] / divisor;
executed (the execution status of this line is deduced): m.m[3][0] = matrix.m[3][0] / divisor;
-
784 m.m[3][1] = matrix.m[3][1] / divisor;
executed (the execution status of this line is deduced): m.m[3][1] = matrix.m[3][1] / divisor;
-
785 m.m[3][2] = matrix.m[3][2] / divisor;
executed (the execution status of this line is deduced): m.m[3][2] = matrix.m[3][2] / divisor;
-
786 m.m[3][3] = matrix.m[3][3] / divisor;
executed (the execution status of this line is deduced): m.m[3][3] = matrix.m[3][3] / divisor;
-
787 m.flagBits = QMatrix4x4::General;
executed (the execution status of this line is deduced): m.flagBits = QMatrix4x4::General;
-
788 return m;
executed: return m;
Execution Count:4
4
789} -
790 -
791/*! -
792 \fn bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2) -
793 \relates QMatrix4x4 -
794 -
795 Returns true if \a m1 and \a m2 are equal, allowing for a small -
796 fuzziness factor for floating-point comparisons; false otherwise. -
797*/ -
798 -
799#ifndef QT_NO_VECTOR3D -
800 -
801/*! -
802 Multiplies this matrix by another that scales coordinates by -
803 the components of \a vector. -
804 -
805 \sa translate(), rotate() -
806*/ -
807void QMatrix4x4::scale(const QVector3D& vector) -
808{ -
809 float vx = vector.x();
executed (the execution status of this line is deduced): float vx = vector.x();
-
810 float vy = vector.y();
executed (the execution status of this line is deduced): float vy = vector.y();
-
811 float vz = vector.z();
executed (the execution status of this line is deduced): float vz = vector.z();
-
812 if (flagBits < Scale) {
evaluated: flagBits < Scale
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:7
7-9
813 m[0][0] = vx;
executed (the execution status of this line is deduced): m[0][0] = vx;
-
814 m[1][1] = vy;
executed (the execution status of this line is deduced): m[1][1] = vy;
-
815 m[2][2] = vz;
executed (the execution status of this line is deduced): m[2][2] = vz;
-
816 } else if (flagBits < Rotation2D) {
executed: }
Execution Count:9
evaluated: flagBits < Rotation2D
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-9
817 m[0][0] *= vx;
executed (the execution status of this line is deduced): m[0][0] *= vx;
-
818 m[1][1] *= vy;
executed (the execution status of this line is deduced): m[1][1] *= vy;
-
819 m[2][2] *= vz;
executed (the execution status of this line is deduced): m[2][2] *= vz;
-
820 } else if (flagBits < Rotation) {
executed: }
Execution Count:2
partially evaluated: flagBits < Rotation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
821 m[0][0] *= vx;
never executed (the execution status of this line is deduced): m[0][0] *= vx;
-
822 m[0][1] *= vx;
never executed (the execution status of this line is deduced): m[0][1] *= vx;
-
823 m[1][0] *= vy;
never executed (the execution status of this line is deduced): m[1][0] *= vy;
-
824 m[1][1] *= vy;
never executed (the execution status of this line is deduced): m[1][1] *= vy;
-
825 m[2][2] *= vz;
never executed (the execution status of this line is deduced): m[2][2] *= vz;
-
826 } else {
never executed: }
0
827 m[0][0] *= vx;
executed (the execution status of this line is deduced): m[0][0] *= vx;
-
828 m[0][1] *= vx;
executed (the execution status of this line is deduced): m[0][1] *= vx;
-
829 m[0][2] *= vx;
executed (the execution status of this line is deduced): m[0][2] *= vx;
-
830 m[0][3] *= vx;
executed (the execution status of this line is deduced): m[0][3] *= vx;
-
831 m[1][0] *= vy;
executed (the execution status of this line is deduced): m[1][0] *= vy;
-
832 m[1][1] *= vy;
executed (the execution status of this line is deduced): m[1][1] *= vy;
-
833 m[1][2] *= vy;
executed (the execution status of this line is deduced): m[1][2] *= vy;
-
834 m[1][3] *= vy;
executed (the execution status of this line is deduced): m[1][3] *= vy;
-
835 m[2][0] *= vz;
executed (the execution status of this line is deduced): m[2][0] *= vz;
-
836 m[2][1] *= vz;
executed (the execution status of this line is deduced): m[2][1] *= vz;
-
837 m[2][2] *= vz;
executed (the execution status of this line is deduced): m[2][2] *= vz;
-
838 m[2][3] *= vz;
executed (the execution status of this line is deduced): m[2][3] *= vz;
-
839 }
executed: }
Execution Count:5
5
840 flagBits |= Scale;
executed (the execution status of this line is deduced): flagBits |= Scale;
-
841}
executed: }
Execution Count:16
16
842 -
843#endif -
844 -
845/*! -
846 \overload -
847 -
848 Multiplies this matrix by another that scales coordinates by the -
849 components \a x, and \a y. -
850 -
851 \sa translate(), rotate() -
852*/ -
853void QMatrix4x4::scale(float x, float y) -
854{ -
855 if (flagBits < Scale) {
evaluated: flagBits < Scale
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
856 m[0][0] = x;
executed (the execution status of this line is deduced): m[0][0] = x;
-
857 m[1][1] = y;
executed (the execution status of this line is deduced): m[1][1] = y;
-
858 } else if (flagBits < Rotation2D) {
executed: }
Execution Count:6
partially evaluated: flagBits < Rotation2D
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-6
859 m[0][0] *= x;
never executed (the execution status of this line is deduced): m[0][0] *= x;
-
860 m[1][1] *= y;
never executed (the execution status of this line is deduced): m[1][1] *= y;
-
861 } else if (flagBits < Rotation) {
never executed: }
partially evaluated: flagBits < Rotation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
862 m[0][0] *= x;
never executed (the execution status of this line is deduced): m[0][0] *= x;
-
863 m[0][1] *= x;
never executed (the execution status of this line is deduced): m[0][1] *= x;
-
864 m[1][0] *= y;
never executed (the execution status of this line is deduced): m[1][0] *= y;
-
865 m[1][1] *= y;
never executed (the execution status of this line is deduced): m[1][1] *= y;
-
866 } else {
never executed: }
0
867 m[0][0] *= x;
executed (the execution status of this line is deduced): m[0][0] *= x;
-
868 m[0][1] *= x;
executed (the execution status of this line is deduced): m[0][1] *= x;
-
869 m[0][2] *= x;
executed (the execution status of this line is deduced): m[0][2] *= x;
-
870 m[0][3] *= x;
executed (the execution status of this line is deduced): m[0][3] *= x;
-
871 m[1][0] *= y;
executed (the execution status of this line is deduced): m[1][0] *= y;
-
872 m[1][1] *= y;
executed (the execution status of this line is deduced): m[1][1] *= y;
-
873 m[1][2] *= y;
executed (the execution status of this line is deduced): m[1][2] *= y;
-
874 m[1][3] *= y;
executed (the execution status of this line is deduced): m[1][3] *= y;
-
875 }
executed: }
Execution Count:2
2
876 flagBits |= Scale;
executed (the execution status of this line is deduced): flagBits |= Scale;
-
877}
executed: }
Execution Count:8
8
878 -
879/*! -
880 \overload -
881 -
882 Multiplies this matrix by another that scales coordinates by the -
883 components \a x, \a y, and \a z. -
884 -
885 \sa translate(), rotate() -
886*/ -
887void QMatrix4x4::scale(float x, float y, float z) -
888{ -
889 if (flagBits < Scale) {
evaluated: flagBits < Scale
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:12
12-17
890 m[0][0] = x;
executed (the execution status of this line is deduced): m[0][0] = x;
-
891 m[1][1] = y;
executed (the execution status of this line is deduced): m[1][1] = y;
-
892 m[2][2] = z;
executed (the execution status of this line is deduced): m[2][2] = z;
-
893 } else if (flagBits < Rotation2D) {
executed: }
Execution Count:17
evaluated: flagBits < Rotation2D
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10
2-17
894 m[0][0] *= x;
executed (the execution status of this line is deduced): m[0][0] *= x;
-
895 m[1][1] *= y;
executed (the execution status of this line is deduced): m[1][1] *= y;
-
896 m[2][2] *= z;
executed (the execution status of this line is deduced): m[2][2] *= z;
-
897 } else if (flagBits < Rotation) {
executed: }
Execution Count:2
partially evaluated: flagBits < Rotation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
898 m[0][0] *= x;
never executed (the execution status of this line is deduced): m[0][0] *= x;
-
899 m[0][1] *= x;
never executed (the execution status of this line is deduced): m[0][1] *= x;
-
900 m[1][0] *= y;
never executed (the execution status of this line is deduced): m[1][0] *= y;
-
901 m[1][1] *= y;
never executed (the execution status of this line is deduced): m[1][1] *= y;
-
902 m[2][2] *= z;
never executed (the execution status of this line is deduced): m[2][2] *= z;
-
903 } else {
never executed: }
0
904 m[0][0] *= x;
executed (the execution status of this line is deduced): m[0][0] *= x;
-
905 m[0][1] *= x;
executed (the execution status of this line is deduced): m[0][1] *= x;
-
906 m[0][2] *= x;
executed (the execution status of this line is deduced): m[0][2] *= x;
-
907 m[0][3] *= x;
executed (the execution status of this line is deduced): m[0][3] *= x;
-
908 m[1][0] *= y;
executed (the execution status of this line is deduced): m[1][0] *= y;
-
909 m[1][1] *= y;
executed (the execution status of this line is deduced): m[1][1] *= y;
-
910 m[1][2] *= y;
executed (the execution status of this line is deduced): m[1][2] *= y;
-
911 m[1][3] *= y;
executed (the execution status of this line is deduced): m[1][3] *= y;
-
912 m[2][0] *= z;
executed (the execution status of this line is deduced): m[2][0] *= z;
-
913 m[2][1] *= z;
executed (the execution status of this line is deduced): m[2][1] *= z;
-
914 m[2][2] *= z;
executed (the execution status of this line is deduced): m[2][2] *= z;
-
915 m[2][3] *= z;
executed (the execution status of this line is deduced): m[2][3] *= z;
-
916 }
executed: }
Execution Count:10
10
917 flagBits |= Scale;
executed (the execution status of this line is deduced): flagBits |= Scale;
-
918}
executed: }
Execution Count:29
29
919 -
920/*! -
921 \overload -
922 -
923 Multiplies this matrix by another that scales coordinates by the -
924 given \a factor. -
925 -
926 \sa translate(), rotate() -
927*/ -
928void QMatrix4x4::scale(float factor) -
929{ -
930 if (flagBits < Scale) {
evaluated: flagBits < Scale
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:5
5-8
931 m[0][0] = factor;
executed (the execution status of this line is deduced): m[0][0] = factor;
-
932 m[1][1] = factor;
executed (the execution status of this line is deduced): m[1][1] = factor;
-
933 m[2][2] = factor;
executed (the execution status of this line is deduced): m[2][2] = factor;
-
934 } else if (flagBits < Rotation2D) {
executed: }
Execution Count:8
evaluated: flagBits < Rotation2D
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-8
935 m[0][0] *= factor;
executed (the execution status of this line is deduced): m[0][0] *= factor;
-
936 m[1][1] *= factor;
executed (the execution status of this line is deduced): m[1][1] *= factor;
-
937 m[2][2] *= factor;
executed (the execution status of this line is deduced): m[2][2] *= factor;
-
938 } else if (flagBits < Rotation) {
executed: }
Execution Count:2
partially evaluated: flagBits < Rotation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
939 m[0][0] *= factor;
never executed (the execution status of this line is deduced): m[0][0] *= factor;
-
940 m[0][1] *= factor;
never executed (the execution status of this line is deduced): m[0][1] *= factor;
-
941 m[1][0] *= factor;
never executed (the execution status of this line is deduced): m[1][0] *= factor;
-
942 m[1][1] *= factor;
never executed (the execution status of this line is deduced): m[1][1] *= factor;
-
943 m[2][2] *= factor;
never executed (the execution status of this line is deduced): m[2][2] *= factor;
-
944 } else {
never executed: }
0
945 m[0][0] *= factor;
executed (the execution status of this line is deduced): m[0][0] *= factor;
-
946 m[0][1] *= factor;
executed (the execution status of this line is deduced): m[0][1] *= factor;
-
947 m[0][2] *= factor;
executed (the execution status of this line is deduced): m[0][2] *= factor;
-
948 m[0][3] *= factor;
executed (the execution status of this line is deduced): m[0][3] *= factor;
-
949 m[1][0] *= factor;
executed (the execution status of this line is deduced): m[1][0] *= factor;
-
950 m[1][1] *= factor;
executed (the execution status of this line is deduced): m[1][1] *= factor;
-
951 m[1][2] *= factor;
executed (the execution status of this line is deduced): m[1][2] *= factor;
-
952 m[1][3] *= factor;
executed (the execution status of this line is deduced): m[1][3] *= factor;
-
953 m[2][0] *= factor;
executed (the execution status of this line is deduced): m[2][0] *= factor;
-
954 m[2][1] *= factor;
executed (the execution status of this line is deduced): m[2][1] *= factor;
-
955 m[2][2] *= factor;
executed (the execution status of this line is deduced): m[2][2] *= factor;
-
956 m[2][3] *= factor;
executed (the execution status of this line is deduced): m[2][3] *= factor;
-
957 }
executed: }
Execution Count:3
3
958 flagBits |= Scale;
executed (the execution status of this line is deduced): flagBits |= Scale;
-
959}
executed: }
Execution Count:13
13
960 -
961#ifndef QT_NO_VECTOR3D -
962/*! -
963 Multiplies this matrix by another that translates coordinates by -
964 the components of \a vector. -
965 -
966 \sa scale(), rotate() -
967*/ -
968 -
969void QMatrix4x4::translate(const QVector3D& vector) -
970{ -
971 float vx = vector.x();
executed (the execution status of this line is deduced): float vx = vector.x();
-
972 float vy = vector.y();
executed (the execution status of this line is deduced): float vy = vector.y();
-
973 float vz = vector.z();
executed (the execution status of this line is deduced): float vz = vector.z();
-
974 if (flagBits == Identity) {
evaluated: flagBits == Identity
TRUEFALSE
yes
Evaluation Count:5777
yes
Evaluation Count:5773
5773-5777
975 m[3][0] = vx;
executed (the execution status of this line is deduced): m[3][0] = vx;
-
976 m[3][1] = vy;
executed (the execution status of this line is deduced): m[3][1] = vy;
-
977 m[3][2] = vz;
executed (the execution status of this line is deduced): m[3][2] = vz;
-
978 } else if (flagBits == Translation) {
executed: }
Execution Count:5777
evaluated: flagBits == Translation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5772
1-5777
979 m[3][0] += vx;
executed (the execution status of this line is deduced): m[3][0] += vx;
-
980 m[3][1] += vy;
executed (the execution status of this line is deduced): m[3][1] += vy;
-
981 m[3][2] += vz;
executed (the execution status of this line is deduced): m[3][2] += vz;
-
982 } else if (flagBits == Scale) {
executed: }
Execution Count:1
evaluated: flagBits == Scale
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5771
1-5771
983 m[3][0] = m[0][0] * vx;
executed (the execution status of this line is deduced): m[3][0] = m[0][0] * vx;
-
984 m[3][1] = m[1][1] * vy;
executed (the execution status of this line is deduced): m[3][1] = m[1][1] * vy;
-
985 m[3][2] = m[2][2] * vz;
executed (the execution status of this line is deduced): m[3][2] = m[2][2] * vz;
-
986 } else if (flagBits == (Translation | Scale)) {
executed: }
Execution Count:1
evaluated: flagBits == (Translation | Scale)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:5763
1-5763
987 m[3][0] += m[0][0] * vx;
executed (the execution status of this line is deduced): m[3][0] += m[0][0] * vx;
-
988 m[3][1] += m[1][1] * vy;
executed (the execution status of this line is deduced): m[3][1] += m[1][1] * vy;
-
989 m[3][2] += m[2][2] * vz;
executed (the execution status of this line is deduced): m[3][2] += m[2][2] * vz;
-
990 } else if (flagBits < Rotation) {
executed: }
Execution Count:8
evaluated: flagBits < Rotation
TRUEFALSE
yes
Evaluation Count:723
yes
Evaluation Count:5040
8-5040
991 m[3][0] += m[0][0] * vx + m[1][0] * vy;
executed (the execution status of this line is deduced): m[3][0] += m[0][0] * vx + m[1][0] * vy;
-
992 m[3][1] += m[0][1] * vx + m[1][1] * vy;
executed (the execution status of this line is deduced): m[3][1] += m[0][1] * vx + m[1][1] * vy;
-
993 m[3][2] += m[2][2] * vz;
executed (the execution status of this line is deduced): m[3][2] += m[2][2] * vz;
-
994 } else {
executed: }
Execution Count:723
723
995 m[3][0] += m[0][0] * vx + m[1][0] * vy + m[2][0] * vz;
executed (the execution status of this line is deduced): m[3][0] += m[0][0] * vx + m[1][0] * vy + m[2][0] * vz;
-
996 m[3][1] += m[0][1] * vx + m[1][1] * vy + m[2][1] * vz;
executed (the execution status of this line is deduced): m[3][1] += m[0][1] * vx + m[1][1] * vy + m[2][1] * vz;
-
997 m[3][2] += m[0][2] * vx + m[1][2] * vy + m[2][2] * vz;
executed (the execution status of this line is deduced): m[3][2] += m[0][2] * vx + m[1][2] * vy + m[2][2] * vz;
-
998 m[3][3] += m[0][3] * vx + m[1][3] * vy + m[2][3] * vz;
executed (the execution status of this line is deduced): m[3][3] += m[0][3] * vx + m[1][3] * vy + m[2][3] * vz;
-
999 }
executed: }
Execution Count:5040
5040
1000 flagBits |= Translation;
executed (the execution status of this line is deduced): flagBits |= Translation;
-
1001}
executed: }
Execution Count:11550
11550
1002#endif -
1003 -
1004/*! -
1005 \overload -
1006 -
1007 Multiplies this matrix by another that translates coordinates -
1008 by the components \a x, and \a y. -
1009 -
1010 \sa scale(), rotate() -
1011*/ -
1012void QMatrix4x4::translate(float x, float y) -
1013{ -
1014 if (flagBits == Identity) {
evaluated: flagBits == Identity
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
1015 m[3][0] = x;
executed (the execution status of this line is deduced): m[3][0] = x;
-
1016 m[3][1] = y;
executed (the execution status of this line is deduced): m[3][1] = y;
-
1017 } else if (flagBits == Translation) {
executed: }
Execution Count:6
partially evaluated: flagBits == Translation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-6
1018 m[3][0] += x;
never executed (the execution status of this line is deduced): m[3][0] += x;
-
1019 m[3][1] += y;
never executed (the execution status of this line is deduced): m[3][1] += y;
-
1020 } else if (flagBits == Scale) {
never executed: }
partially evaluated: flagBits == Scale
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1021 m[3][0] = m[0][0] * x;
never executed (the execution status of this line is deduced): m[3][0] = m[0][0] * x;
-
1022 m[3][1] = m[1][1] * y;
never executed (the execution status of this line is deduced): m[3][1] = m[1][1] * y;
-
1023 } else if (flagBits == (Translation | Scale)) {
never executed: }
partially evaluated: flagBits == (Translation | Scale)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1024 m[3][0] += m[0][0] * x;
never executed (the execution status of this line is deduced): m[3][0] += m[0][0] * x;
-
1025 m[3][1] += m[1][1] * y;
never executed (the execution status of this line is deduced): m[3][1] += m[1][1] * y;
-
1026 } else if (flagBits < Rotation) {
never executed: }
partially evaluated: flagBits < Rotation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1027 m[3][0] += m[0][0] * x + m[1][0] * y;
never executed (the execution status of this line is deduced): m[3][0] += m[0][0] * x + m[1][0] * y;
-
1028 m[3][1] += m[0][1] * x + m[1][1] * y;
never executed (the execution status of this line is deduced): m[3][1] += m[0][1] * x + m[1][1] * y;
-
1029 } else {
never executed: }
0
1030 m[3][0] += m[0][0] * x + m[1][0] * y;
executed (the execution status of this line is deduced): m[3][0] += m[0][0] * x + m[1][0] * y;
-
1031 m[3][1] += m[0][1] * x + m[1][1] * y;
executed (the execution status of this line is deduced): m[3][1] += m[0][1] * x + m[1][1] * y;
-
1032 m[3][2] += m[0][2] * x + m[1][2] * y;
executed (the execution status of this line is deduced): m[3][2] += m[0][2] * x + m[1][2] * y;
-
1033 m[3][3] += m[0][3] * x + m[1][3] * y;
executed (the execution status of this line is deduced): m[3][3] += m[0][3] * x + m[1][3] * y;
-
1034 }
executed: }
Execution Count:2
2
1035 flagBits |= Translation;
executed (the execution status of this line is deduced): flagBits |= Translation;
-
1036}
executed: }
Execution Count:8
8
1037 -
1038/*! -
1039 \overload -
1040 -
1041 Multiplies this matrix by another that translates coordinates -
1042 by the components \a x, \a y, and \a z. -
1043 -
1044 \sa scale(), rotate() -
1045*/ -
1046void QMatrix4x4::translate(float x, float y, float z) -
1047{ -
1048 if (flagBits == Identity) {
evaluated: flagBits == Identity
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:9
9-11
1049 m[3][0] = x;
executed (the execution status of this line is deduced): m[3][0] = x;
-
1050 m[3][1] = y;
executed (the execution status of this line is deduced): m[3][1] = y;
-
1051 m[3][2] = z;
executed (the execution status of this line is deduced): m[3][2] = z;
-
1052 } else if (flagBits == Translation) {
executed: }
Execution Count:11
evaluated: flagBits == Translation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-11
1053 m[3][0] += x;
executed (the execution status of this line is deduced): m[3][0] += x;
-
1054 m[3][1] += y;
executed (the execution status of this line is deduced): m[3][1] += y;
-
1055 m[3][2] += z;
executed (the execution status of this line is deduced): m[3][2] += z;
-
1056 } else if (flagBits == Scale) {
executed: }
Execution Count:1
evaluated: flagBits == Scale
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
1057 m[3][0] = m[0][0] * x;
executed (the execution status of this line is deduced): m[3][0] = m[0][0] * x;
-
1058 m[3][1] = m[1][1] * y;
executed (the execution status of this line is deduced): m[3][1] = m[1][1] * y;
-
1059 m[3][2] = m[2][2] * z;
executed (the execution status of this line is deduced): m[3][2] = m[2][2] * z;
-
1060 } else if (flagBits == (Translation | Scale)) {
executed: }
Execution Count:1
evaluated: flagBits == (Translation | Scale)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
1061 m[3][0] += m[0][0] * x;
executed (the execution status of this line is deduced): m[3][0] += m[0][0] * x;
-
1062 m[3][1] += m[1][1] * y;
executed (the execution status of this line is deduced): m[3][1] += m[1][1] * y;
-
1063 m[3][2] += m[2][2] * z;
executed (the execution status of this line is deduced): m[3][2] += m[2][2] * z;
-
1064 } else if (flagBits < Rotation) {
executed: }
Execution Count:1
evaluated: flagBits < Rotation
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
1065 m[3][0] += m[0][0] * x + m[1][0] * y;
executed (the execution status of this line is deduced): m[3][0] += m[0][0] * x + m[1][0] * y;
-
1066 m[3][1] += m[0][1] * x + m[1][1] * y;
executed (the execution status of this line is deduced): m[3][1] += m[0][1] * x + m[1][1] * y;
-
1067 m[3][2] += m[2][2] * z;
executed (the execution status of this line is deduced): m[3][2] += m[2][2] * z;
-
1068 } else {
executed: }
Execution Count:1
1
1069 m[3][0] += m[0][0] * x + m[1][0] * y + m[2][0] * z;
executed (the execution status of this line is deduced): m[3][0] += m[0][0] * x + m[1][0] * y + m[2][0] * z;
-
1070 m[3][1] += m[0][1] * x + m[1][1] * y + m[2][1] * z;
executed (the execution status of this line is deduced): m[3][1] += m[0][1] * x + m[1][1] * y + m[2][1] * z;
-
1071 m[3][2] += m[0][2] * x + m[1][2] * y + m[2][2] * z;
executed (the execution status of this line is deduced): m[3][2] += m[0][2] * x + m[1][2] * y + m[2][2] * z;
-
1072 m[3][3] += m[0][3] * x + m[1][3] * y + m[2][3] * z;
executed (the execution status of this line is deduced): m[3][3] += m[0][3] * x + m[1][3] * y + m[2][3] * z;
-
1073 }
executed: }
Execution Count:5
5
1074 flagBits |= Translation;
executed (the execution status of this line is deduced): flagBits |= Translation;
-
1075}
executed: }
Execution Count:20
20
1076 -
1077#ifndef QT_NO_VECTOR3D -
1078/*! -
1079 Multiples this matrix by another that rotates coordinates through -
1080 \a angle degrees about \a vector. -
1081 -
1082 \sa scale(), translate() -
1083*/ -
1084 -
1085void QMatrix4x4::rotate(float angle, const QVector3D& vector) -
1086{ -
1087 rotate(angle, vector.x(), vector.y(), vector.z());
executed (the execution status of this line is deduced): rotate(angle, vector.x(), vector.y(), vector.z());
-
1088}
executed: }
Execution Count:1814
1814
1089 -
1090#endif -
1091 -
1092/*! -
1093 \overload -
1094 -
1095 Multiplies this matrix by another that rotates coordinates through -
1096 \a angle degrees about the vector (\a x, \a y, \a z). -
1097 -
1098 \sa scale(), translate() -
1099*/ -
1100void QMatrix4x4::rotate(float angle, float x, float y, float z) -
1101{ -
1102 if (angle == 0.0f)
evaluated: angle == 0.0f
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1831
8-1831
1103 return;
executed: return;
Execution Count:8
8
1104 float c, s;
executed (the execution status of this line is deduced): float c, s;
-
1105 if (angle == 90.0f || angle == -270.0f) {
evaluated: angle == 90.0f
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:1804
partially evaluated: angle == -270.0f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1804
0-1804
1106 s = 1.0f;
executed (the execution status of this line is deduced): s = 1.0f;
-
1107 c = 0.0f;
executed (the execution status of this line is deduced): c = 0.0f;
-
1108 } else if (angle == -90.0f || angle == 270.0f) {
executed: }
Execution Count:27
partially evaluated: angle == -90.0f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1804
evaluated: angle == 270.0f
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1799
0-1804
1109 s = -1.0f;
executed (the execution status of this line is deduced): s = -1.0f;
-
1110 c = 0.0f;
executed (the execution status of this line is deduced): c = 0.0f;
-
1111 } else if (angle == 180.0f || angle == -180.0f) {
executed: }
Execution Count:5
evaluated: angle == 180.0f
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1794
partially evaluated: angle == -180.0f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1794
0-1794
1112 s = 0.0f;
executed (the execution status of this line is deduced): s = 0.0f;
-
1113 c = -1.0f;
executed (the execution status of this line is deduced): c = -1.0f;
-
1114 } else {
executed: }
Execution Count:5
5
1115 float a = angle * M_PI / 180.0f;
executed (the execution status of this line is deduced): float a = angle * 3.14159265358979323846 / 180.0f;
-
1116 c = cosf(a);
executed (the execution status of this line is deduced): c = cosf(a);
-
1117 s = sinf(a);
executed (the execution status of this line is deduced): s = sinf(a);
-
1118 }
executed: }
Execution Count:1794
1794
1119 if (x == 0.0f) {
evaluated: x == 0.0f
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:1811
20-1811
1120 if (y == 0.0f) {
evaluated: y == 0.0f
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:7
7-13
1121 if (z != 0.0f) {
evaluated: z != 0.0f
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
3-10
1122 // Rotate around the Z axis. -
1123 if (z < 0)
evaluated: z < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
3-7
1124 s = -s;
executed: s = -s;
Execution Count:3
3
1125 float tmp;
executed (the execution status of this line is deduced): float tmp;
-
1126 m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s;
executed (the execution status of this line is deduced): m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s;
-
1127 m[1][0] = m[1][0] * c - tmp * s;
executed (the execution status of this line is deduced): m[1][0] = m[1][0] * c - tmp * s;
-
1128 m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s;
executed (the execution status of this line is deduced): m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s;
-
1129 m[1][1] = m[1][1] * c - tmp * s;
executed (the execution status of this line is deduced): m[1][1] = m[1][1] * c - tmp * s;
-
1130 m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s;
executed (the execution status of this line is deduced): m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s;
-
1131 m[1][2] = m[1][2] * c - tmp * s;
executed (the execution status of this line is deduced): m[1][2] = m[1][2] * c - tmp * s;
-
1132 m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s;
executed (the execution status of this line is deduced): m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s;
-
1133 m[1][3] = m[1][3] * c - tmp * s;
executed (the execution status of this line is deduced): m[1][3] = m[1][3] * c - tmp * s;
-
1134 -
1135 flagBits |= Rotation2D;
executed (the execution status of this line is deduced): flagBits |= Rotation2D;
-
1136 return;
executed: return;
Execution Count:10
10
1137 } -
1138 } else if (z == 0.0f) {
executed: }
Execution Count:3
partially evaluated: z == 0.0f
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
1139 // Rotate around the Y axis. -
1140 if (y < 0)
evaluated: y < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
3-4
1141 s = -s;
executed: s = -s;
Execution Count:3
3
1142 float tmp;
executed (the execution status of this line is deduced): float tmp;
-
1143 m[2][0] = (tmp = m[2][0]) * c + m[0][0] * s;
executed (the execution status of this line is deduced): m[2][0] = (tmp = m[2][0]) * c + m[0][0] * s;
-
1144 m[0][0] = m[0][0] * c - tmp * s;
executed (the execution status of this line is deduced): m[0][0] = m[0][0] * c - tmp * s;
-
1145 m[2][1] = (tmp = m[2][1]) * c + m[0][1] * s;
executed (the execution status of this line is deduced): m[2][1] = (tmp = m[2][1]) * c + m[0][1] * s;
-
1146 m[0][1] = m[0][1] * c - tmp * s;
executed (the execution status of this line is deduced): m[0][1] = m[0][1] * c - tmp * s;
-
1147 m[2][2] = (tmp = m[2][2]) * c + m[0][2] * s;
executed (the execution status of this line is deduced): m[2][2] = (tmp = m[2][2]) * c + m[0][2] * s;
-
1148 m[0][2] = m[0][2] * c - tmp * s;
executed (the execution status of this line is deduced): m[0][2] = m[0][2] * c - tmp * s;
-
1149 m[2][3] = (tmp = m[2][3]) * c + m[0][3] * s;
executed (the execution status of this line is deduced): m[2][3] = (tmp = m[2][3]) * c + m[0][3] * s;
-
1150 m[0][3] = m[0][3] * c - tmp * s;
executed (the execution status of this line is deduced): m[0][3] = m[0][3] * c - tmp * s;
-
1151 -
1152 flagBits |= Rotation;
executed (the execution status of this line is deduced): flagBits |= Rotation;
-
1153 return;
executed: return;
Execution Count:7
7
1154 } -
1155 } else if (y == 0.0f && z == 0.0f) {
evaluated: y == 0.0f
TRUEFALSE
yes
Evaluation Count:368
yes
Evaluation Count:1443
evaluated: z == 0.0f
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:360
8-1443
1156 // Rotate around the X axis. -
1157 if (x < 0)
evaluated: x < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5
3-5
1158 s = -s;
executed: s = -s;
Execution Count:3
3
1159 float tmp;
executed (the execution status of this line is deduced): float tmp;
-
1160 m[1][0] = (tmp = m[1][0]) * c + m[2][0] * s;
executed (the execution status of this line is deduced): m[1][0] = (tmp = m[1][0]) * c + m[2][0] * s;
-
1161 m[2][0] = m[2][0] * c - tmp * s;
executed (the execution status of this line is deduced): m[2][0] = m[2][0] * c - tmp * s;
-
1162 m[1][1] = (tmp = m[1][1]) * c + m[2][1] * s;
executed (the execution status of this line is deduced): m[1][1] = (tmp = m[1][1]) * c + m[2][1] * s;
-
1163 m[2][1] = m[2][1] * c - tmp * s;
executed (the execution status of this line is deduced): m[2][1] = m[2][1] * c - tmp * s;
-
1164 m[1][2] = (tmp = m[1][2]) * c + m[2][2] * s;
executed (the execution status of this line is deduced): m[1][2] = (tmp = m[1][2]) * c + m[2][2] * s;
-
1165 m[2][2] = m[2][2] * c - tmp * s;
executed (the execution status of this line is deduced): m[2][2] = m[2][2] * c - tmp * s;
-
1166 m[1][3] = (tmp = m[1][3]) * c + m[2][3] * s;
executed (the execution status of this line is deduced): m[1][3] = (tmp = m[1][3]) * c + m[2][3] * s;
-
1167 m[2][3] = m[2][3] * c - tmp * s;
executed (the execution status of this line is deduced): m[2][3] = m[2][3] * c - tmp * s;
-
1168 -
1169 flagBits |= Rotation;
executed (the execution status of this line is deduced): flagBits |= Rotation;
-
1170 return;
executed: return;
Execution Count:8
8
1171 } -
1172 -
1173 double len = double(x) * double(x) +
executed (the execution status of this line is deduced): double len = double(x) * double(x) +
-
1174 double(y) * double(y) +
executed (the execution status of this line is deduced): double(y) * double(y) +
-
1175 double(z) * double(z);
executed (the execution status of this line is deduced): double(z) * double(z);
-
1176 if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) {
partially evaluated: !qFuzzyCompare(len, 1.0)
TRUEFALSE
yes
Evaluation Count:1806
no
Evaluation Count:0
evaluated: !qFuzzyIsNull(len)
TRUEFALSE
yes
Evaluation Count:1803
yes
Evaluation Count:3
0-1806
1177 len = sqrt(len);
executed (the execution status of this line is deduced): len = sqrt(len);
-
1178 x = float(double(x) / len);
executed (the execution status of this line is deduced): x = float(double(x) / len);
-
1179 y = float(double(y) / len);
executed (the execution status of this line is deduced): y = float(double(y) / len);
-
1180 z = float(double(z) / len);
executed (the execution status of this line is deduced): z = float(double(z) / len);
-
1181 }
executed: }
Execution Count:1803
1803
1182 float ic = 1.0f - c;
executed (the execution status of this line is deduced): float ic = 1.0f - c;
-
1183 QMatrix4x4 rot(1); // The "1" says to not load the identity.
executed (the execution status of this line is deduced): QMatrix4x4 rot(1);
-
1184 rot.m[0][0] = x * x * ic + c;
executed (the execution status of this line is deduced): rot.m[0][0] = x * x * ic + c;
-
1185 rot.m[1][0] = x * y * ic - z * s;
executed (the execution status of this line is deduced): rot.m[1][0] = x * y * ic - z * s;
-
1186 rot.m[2][0] = x * z * ic + y * s;
executed (the execution status of this line is deduced): rot.m[2][0] = x * z * ic + y * s;
-
1187 rot.m[3][0] = 0.0f;
executed (the execution status of this line is deduced): rot.m[3][0] = 0.0f;
-
1188 rot.m[0][1] = y * x * ic + z * s;
executed (the execution status of this line is deduced): rot.m[0][1] = y * x * ic + z * s;
-
1189 rot.m[1][1] = y * y * ic + c;
executed (the execution status of this line is deduced): rot.m[1][1] = y * y * ic + c;
-
1190 rot.m[2][1] = y * z * ic - x * s;
executed (the execution status of this line is deduced): rot.m[2][1] = y * z * ic - x * s;
-
1191 rot.m[3][1] = 0.0f;
executed (the execution status of this line is deduced): rot.m[3][1] = 0.0f;
-
1192 rot.m[0][2] = x * z * ic - y * s;
executed (the execution status of this line is deduced): rot.m[0][2] = x * z * ic - y * s;
-
1193 rot.m[1][2] = y * z * ic + x * s;
executed (the execution status of this line is deduced): rot.m[1][2] = y * z * ic + x * s;
-
1194 rot.m[2][2] = z * z * ic + c;
executed (the execution status of this line is deduced): rot.m[2][2] = z * z * ic + c;
-
1195 rot.m[3][2] = 0.0f;
executed (the execution status of this line is deduced): rot.m[3][2] = 0.0f;
-
1196 rot.m[0][3] = 0.0f;
executed (the execution status of this line is deduced): rot.m[0][3] = 0.0f;
-
1197 rot.m[1][3] = 0.0f;
executed (the execution status of this line is deduced): rot.m[1][3] = 0.0f;
-
1198 rot.m[2][3] = 0.0f;
executed (the execution status of this line is deduced): rot.m[2][3] = 0.0f;
-
1199 rot.m[3][3] = 1.0f;
executed (the execution status of this line is deduced): rot.m[3][3] = 1.0f;
-
1200 rot.flagBits = Rotation;
executed (the execution status of this line is deduced): rot.flagBits = Rotation;
-
1201 *this *= rot;
executed (the execution status of this line is deduced): *this *= rot;
-
1202}
executed: }
Execution Count:1806
1806
1203 -
1204/*! -
1205 \internal -
1206*/ -
1207void QMatrix4x4::projectedRotate(float angle, float x, float y, float z) -
1208{ -
1209 // Used by QGraphicsRotation::applyTo() to perform a rotation -
1210 // and projection back to 2D in a single step. -
1211 if (angle == 0.0f)
partially evaluated: angle == 0.0f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5763
0-5763
1212 return;
never executed: return;
0
1213 float c, s;
executed (the execution status of this line is deduced): float c, s;
-
1214 if (angle == 90.0f || angle == -270.0f) {
evaluated: angle == 90.0f
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:5745
partially evaluated: angle == -270.0f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5745
0-5745
1215 s = 1.0f;
executed (the execution status of this line is deduced): s = 1.0f;
-
1216 c = 0.0f;
executed (the execution status of this line is deduced): c = 0.0f;
-
1217 } else if (angle == -90.0f || angle == 270.0f) {
executed: }
Execution Count:18
partially evaluated: angle == -90.0f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5745
evaluated: angle == 270.0f
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:5729
0-5745
1218 s = -1.0f;
executed (the execution status of this line is deduced): s = -1.0f;
-
1219 c = 0.0f;
executed (the execution status of this line is deduced): c = 0.0f;
-
1220 } else if (angle == 180.0f || angle == -180.0f) {
executed: }
Execution Count:16
evaluated: angle == 180.0f
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:5713
partially evaluated: angle == -180.0f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5713
0-5713
1221 s = 0.0f;
executed (the execution status of this line is deduced): s = 0.0f;
-
1222 c = -1.0f;
executed (the execution status of this line is deduced): c = -1.0f;
-
1223 } else {
executed: }
Execution Count:16
16
1224 float a = angle * M_PI / 180.0f;
executed (the execution status of this line is deduced): float a = angle * 3.14159265358979323846 / 180.0f;
-
1225 c = cosf(a);
executed (the execution status of this line is deduced): c = cosf(a);
-
1226 s = sinf(a);
executed (the execution status of this line is deduced): s = sinf(a);
-
1227 }
executed: }
Execution Count:5713
5713
1228 if (x == 0.0f) {
evaluated: x == 0.0f
TRUEFALSE
yes
Evaluation Count:1443
yes
Evaluation Count:4320
1443-4320
1229 if (y == 0.0f) {
evaluated: y == 0.0f
TRUEFALSE
yes
Evaluation Count:723
yes
Evaluation Count:720
720-723
1230 if (z != 0.0f) {
partially evaluated: z != 0.0f
TRUEFALSE
yes
Evaluation Count:723
no
Evaluation Count:0
0-723
1231 // Rotate around the Z axis. -
1232 if (z < 0)
partially evaluated: z < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:723
0-723
1233 s = -s;
never executed: s = -s;
0
1234 float tmp;
executed (the execution status of this line is deduced): float tmp;
-
1235 m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s;
executed (the execution status of this line is deduced): m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s;
-
1236 m[1][0] = m[1][0] * c - tmp * s;
executed (the execution status of this line is deduced): m[1][0] = m[1][0] * c - tmp * s;
-
1237 m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s;
executed (the execution status of this line is deduced): m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s;
-
1238 m[1][1] = m[1][1] * c - tmp * s;
executed (the execution status of this line is deduced): m[1][1] = m[1][1] * c - tmp * s;
-
1239 m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s;
executed (the execution status of this line is deduced): m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s;
-
1240 m[1][2] = m[1][2] * c - tmp * s;
executed (the execution status of this line is deduced): m[1][2] = m[1][2] * c - tmp * s;
-
1241 m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s;
executed (the execution status of this line is deduced): m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s;
-
1242 m[1][3] = m[1][3] * c - tmp * s;
executed (the execution status of this line is deduced): m[1][3] = m[1][3] * c - tmp * s;
-
1243 -
1244 flagBits |= Rotation2D;
executed (the execution status of this line is deduced): flagBits |= Rotation2D;
-
1245 return;
executed: return;
Execution Count:723
723
1246 } -
1247 } else if (z == 0.0f) {
never executed: }
partially evaluated: z == 0.0f
TRUEFALSE
yes
Evaluation Count:720
no
Evaluation Count:0
0-720
1248 // Rotate around the Y axis. -
1249 if (y < 0)
partially evaluated: y < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:720
0-720
1250 s = -s;
never executed: s = -s;
0
1251 m[0][0] = m[0][0] * c + m[3][0] * s * inv_dist_to_plane;
executed (the execution status of this line is deduced): m[0][0] = m[0][0] * c + m[3][0] * s * inv_dist_to_plane;
-
1252 m[0][1] = m[0][1] * c + m[3][1] * s * inv_dist_to_plane;
executed (the execution status of this line is deduced): m[0][1] = m[0][1] * c + m[3][1] * s * inv_dist_to_plane;
-
1253 m[0][2] = m[0][2] * c + m[3][2] * s * inv_dist_to_plane;
executed (the execution status of this line is deduced): m[0][2] = m[0][2] * c + m[3][2] * s * inv_dist_to_plane;
-
1254 m[0][3] = m[0][3] * c + m[3][3] * s * inv_dist_to_plane;
executed (the execution status of this line is deduced): m[0][3] = m[0][3] * c + m[3][3] * s * inv_dist_to_plane;
-
1255 flagBits = General;
executed (the execution status of this line is deduced): flagBits = General;
-
1256 return;
executed: return;
Execution Count:720
720
1257 } -
1258 } else if (y == 0.0f && z == 0.0f) {
evaluated: y == 0.0f
TRUEFALSE
yes
Evaluation Count:1440
yes
Evaluation Count:2880
evaluated: z == 0.0f
TRUEFALSE
yes
Evaluation Count:720
yes
Evaluation Count:720
720-2880
1259 // Rotate around the X axis. -
1260 if (x < 0)
partially evaluated: x < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:720
0-720
1261 s = -s;
never executed: s = -s;
0
1262 m[1][0] = m[1][0] * c - m[3][0] * s * inv_dist_to_plane;
executed (the execution status of this line is deduced): m[1][0] = m[1][0] * c - m[3][0] * s * inv_dist_to_plane;
-
1263 m[1][1] = m[1][1] * c - m[3][1] * s * inv_dist_to_plane;
executed (the execution status of this line is deduced): m[1][1] = m[1][1] * c - m[3][1] * s * inv_dist_to_plane;
-
1264 m[1][2] = m[1][2] * c - m[3][2] * s * inv_dist_to_plane;
executed (the execution status of this line is deduced): m[1][2] = m[1][2] * c - m[3][2] * s * inv_dist_to_plane;
-
1265 m[1][3] = m[1][3] * c - m[3][3] * s * inv_dist_to_plane;
executed (the execution status of this line is deduced): m[1][3] = m[1][3] * c - m[3][3] * s * inv_dist_to_plane;
-
1266 flagBits = General;
executed (the execution status of this line is deduced): flagBits = General;
-
1267 return;
executed: return;
Execution Count:720
720
1268 } -
1269 double len = double(x) * double(x) +
executed (the execution status of this line is deduced): double len = double(x) * double(x) +
-
1270 double(y) * double(y) +
executed (the execution status of this line is deduced): double(y) * double(y) +
-
1271 double(z) * double(z);
executed (the execution status of this line is deduced): double(z) * double(z);
-
1272 if (!qFuzzyCompare(len, 1.0) && !qFuzzyIsNull(len)) {
partially evaluated: !qFuzzyCompare(len, 1.0)
TRUEFALSE
yes
Evaluation Count:3600
no
Evaluation Count:0
partially evaluated: !qFuzzyIsNull(len)
TRUEFALSE
yes
Evaluation Count:3600
no
Evaluation Count:0
0-3600
1273 len = sqrt(len);
executed (the execution status of this line is deduced): len = sqrt(len);
-
1274 x = float(double(x) / len);
executed (the execution status of this line is deduced): x = float(double(x) / len);
-
1275 y = float(double(y) / len);
executed (the execution status of this line is deduced): y = float(double(y) / len);
-
1276 z = float(double(z) / len);
executed (the execution status of this line is deduced): z = float(double(z) / len);
-
1277 }
executed: }
Execution Count:3600
3600
1278 float ic = 1.0f - c;
executed (the execution status of this line is deduced): float ic = 1.0f - c;
-
1279 QMatrix4x4 rot(1); // The "1" says to not load the identity.
executed (the execution status of this line is deduced): QMatrix4x4 rot(1);
-
1280 rot.m[0][0] = x * x * ic + c;
executed (the execution status of this line is deduced): rot.m[0][0] = x * x * ic + c;
-
1281 rot.m[1][0] = x * y * ic - z * s;
executed (the execution status of this line is deduced): rot.m[1][0] = x * y * ic - z * s;
-
1282 rot.m[2][0] = 0.0f;
executed (the execution status of this line is deduced): rot.m[2][0] = 0.0f;
-
1283 rot.m[3][0] = 0.0f;
executed (the execution status of this line is deduced): rot.m[3][0] = 0.0f;
-
1284 rot.m[0][1] = y * x * ic + z * s;
executed (the execution status of this line is deduced): rot.m[0][1] = y * x * ic + z * s;
-
1285 rot.m[1][1] = y * y * ic + c;
executed (the execution status of this line is deduced): rot.m[1][1] = y * y * ic + c;
-
1286 rot.m[2][1] = 0.0f;
executed (the execution status of this line is deduced): rot.m[2][1] = 0.0f;
-
1287 rot.m[3][1] = 0.0f;
executed (the execution status of this line is deduced): rot.m[3][1] = 0.0f;
-
1288 rot.m[0][2] = 0.0f;
executed (the execution status of this line is deduced): rot.m[0][2] = 0.0f;
-
1289 rot.m[1][2] = 0.0f;
executed (the execution status of this line is deduced): rot.m[1][2] = 0.0f;
-
1290 rot.m[2][2] = 1.0f;
executed (the execution status of this line is deduced): rot.m[2][2] = 1.0f;
-
1291 rot.m[3][2] = 0.0f;
executed (the execution status of this line is deduced): rot.m[3][2] = 0.0f;
-
1292 rot.m[0][3] = (x * z * ic - y * s) * -inv_dist_to_plane;
executed (the execution status of this line is deduced): rot.m[0][3] = (x * z * ic - y * s) * -inv_dist_to_plane;
-
1293 rot.m[1][3] = (y * z * ic + x * s) * -inv_dist_to_plane;
executed (the execution status of this line is deduced): rot.m[1][3] = (y * z * ic + x * s) * -inv_dist_to_plane;
-
1294 rot.m[2][3] = 0.0f;
executed (the execution status of this line is deduced): rot.m[2][3] = 0.0f;
-
1295 rot.m[3][3] = 1.0f;
executed (the execution status of this line is deduced): rot.m[3][3] = 1.0f;
-
1296 rot.flagBits = General;
executed (the execution status of this line is deduced): rot.flagBits = General;
-
1297 *this *= rot;
executed (the execution status of this line is deduced): *this *= rot;
-
1298}
executed: }
Execution Count:3600
3600
1299 -
1300#ifndef QT_NO_QUATERNION -
1301 -
1302/*! -
1303 Multiples this matrix by another that rotates coordinates according -
1304 to a specified \a quaternion. The \a quaternion is assumed to have -
1305 been normalized. -
1306 -
1307 \sa scale(), translate(), QQuaternion -
1308*/ -
1309void QMatrix4x4::rotate(const QQuaternion& quaternion) -
1310{ -
1311 // Algorithm from: -
1312 // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54 -
1313 QMatrix4x4 m(1);
executed (the execution status of this line is deduced): QMatrix4x4 m(1);
-
1314 float xx = quaternion.x() * quaternion.x();
executed (the execution status of this line is deduced): float xx = quaternion.x() * quaternion.x();
-
1315 float xy = quaternion.x() * quaternion.y();
executed (the execution status of this line is deduced): float xy = quaternion.x() * quaternion.y();
-
1316 float xz = quaternion.x() * quaternion.z();
executed (the execution status of this line is deduced): float xz = quaternion.x() * quaternion.z();
-
1317 float xw = quaternion.x() * quaternion.scalar();
executed (the execution status of this line is deduced): float xw = quaternion.x() * quaternion.scalar();
-
1318 float yy = quaternion.y() * quaternion.y();
executed (the execution status of this line is deduced): float yy = quaternion.y() * quaternion.y();
-
1319 float yz = quaternion.y() * quaternion.z();
executed (the execution status of this line is deduced): float yz = quaternion.y() * quaternion.z();
-
1320 float yw = quaternion.y() * quaternion.scalar();
executed (the execution status of this line is deduced): float yw = quaternion.y() * quaternion.scalar();
-
1321 float zz = quaternion.z() * quaternion.z();
executed (the execution status of this line is deduced): float zz = quaternion.z() * quaternion.z();
-
1322 float zw = quaternion.z() * quaternion.scalar();
executed (the execution status of this line is deduced): float zw = quaternion.z() * quaternion.scalar();
-
1323 m.m[0][0] = 1.0f - 2 * (yy + zz);
executed (the execution status of this line is deduced): m.m[0][0] = 1.0f - 2 * (yy + zz);
-
1324 m.m[1][0] = 2 * (xy - zw);
executed (the execution status of this line is deduced): m.m[1][0] = 2 * (xy - zw);
-
1325 m.m[2][0] = 2 * (xz + yw);
executed (the execution status of this line is deduced): m.m[2][0] = 2 * (xz + yw);
-
1326 m.m[3][0] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][0] = 0.0f;
-
1327 m.m[0][1] = 2 * (xy + zw);
executed (the execution status of this line is deduced): m.m[0][1] = 2 * (xy + zw);
-
1328 m.m[1][1] = 1.0f - 2 * (xx + zz);
executed (the execution status of this line is deduced): m.m[1][1] = 1.0f - 2 * (xx + zz);
-
1329 m.m[2][1] = 2 * (yz - xw);
executed (the execution status of this line is deduced): m.m[2][1] = 2 * (yz - xw);
-
1330 m.m[3][1] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][1] = 0.0f;
-
1331 m.m[0][2] = 2 * (xz - yw);
executed (the execution status of this line is deduced): m.m[0][2] = 2 * (xz - yw);
-
1332 m.m[1][2] = 2 * (yz + xw);
executed (the execution status of this line is deduced): m.m[1][2] = 2 * (yz + xw);
-
1333 m.m[2][2] = 1.0f - 2 * (xx + yy);
executed (the execution status of this line is deduced): m.m[2][2] = 1.0f - 2 * (xx + yy);
-
1334 m.m[3][2] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][2] = 0.0f;
-
1335 m.m[0][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][3] = 0.0f;
-
1336 m.m[1][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][3] = 0.0f;
-
1337 m.m[2][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[2][3] = 0.0f;
-
1338 m.m[3][3] = 1.0f;
executed (the execution status of this line is deduced): m.m[3][3] = 1.0f;
-
1339 m.flagBits = Rotation;
executed (the execution status of this line is deduced): m.flagBits = Rotation;
-
1340 *this *= m;
executed (the execution status of this line is deduced): *this *= m;
-
1341}
executed: }
Execution Count:8
8
1342 -
1343#endif -
1344 -
1345/*! -
1346 \overload -
1347 -
1348 Multiplies this matrix by another that applies an orthographic -
1349 projection for a window with boundaries specified by \a rect. -
1350 The near and far clipping planes will be -1 and 1 respectively. -
1351 -
1352 \sa frustum(), perspective() -
1353*/ -
1354void QMatrix4x4::ortho(const QRect& rect) -
1355{ -
1356 // Note: rect.right() and rect.bottom() subtract 1 in QRect, -
1357 // which gives the location of a pixel within the rectangle, -
1358 // instead of the extent of the rectangle. We want the extent. -
1359 // QRectF expresses the extent properly. -
1360 ortho(rect.x(), rect.x() + rect.width(), rect.y() + rect.height(), rect.y(), -1.0f, 1.0f);
executed (the execution status of this line is deduced): ortho(rect.x(), rect.x() + rect.width(), rect.y() + rect.height(), rect.y(), -1.0f, 1.0f);
-
1361}
executed: }
Execution Count:1
1
1362 -
1363/*! -
1364 \overload -
1365 -
1366 Multiplies this matrix by another that applies an orthographic -
1367 projection for a window with boundaries specified by \a rect. -
1368 The near and far clipping planes will be -1 and 1 respectively. -
1369 -
1370 \sa frustum(), perspective() -
1371*/ -
1372void QMatrix4x4::ortho(const QRectF& rect) -
1373{ -
1374 ortho(rect.left(), rect.right(), rect.bottom(), rect.top(), -1.0f, 1.0f);
executed (the execution status of this line is deduced): ortho(rect.left(), rect.right(), rect.bottom(), rect.top(), -1.0f, 1.0f);
-
1375}
executed: }
Execution Count:1
1
1376 -
1377/*! -
1378 Multiplies this matrix by another that applies an orthographic -
1379 projection for a window with lower-left corner (\a left, \a bottom), -
1380 upper-right corner (\a right, \a top), and the specified \a nearPlane -
1381 and \a farPlane clipping planes. -
1382 -
1383 \sa frustum(), perspective() -
1384*/ -
1385void QMatrix4x4::ortho(float left, float right, float bottom, float top, float nearPlane, float farPlane) -
1386{ -
1387 // Bail out if the projection volume is zero-sized. -
1388 if (left == right || bottom == top || nearPlane == farPlane)
evaluated: left == right
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
evaluated: bottom == top
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
evaluated: nearPlane == farPlane
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-6
1389 return;
executed: return;
Execution Count:3
3
1390 -
1391 // Construct the projection. -
1392 float width = right - left;
executed (the execution status of this line is deduced): float width = right - left;
-
1393 float invheight = top - bottom;
executed (the execution status of this line is deduced): float invheight = top - bottom;
-
1394 float clip = farPlane - nearPlane;
executed (the execution status of this line is deduced): float clip = farPlane - nearPlane;
-
1395 QMatrix4x4 m(1);
executed (the execution status of this line is deduced): QMatrix4x4 m(1);
-
1396 m.m[0][0] = 2.0f / width;
executed (the execution status of this line is deduced): m.m[0][0] = 2.0f / width;
-
1397 m.m[1][0] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][0] = 0.0f;
-
1398 m.m[2][0] = 0.0f;
executed (the execution status of this line is deduced): m.m[2][0] = 0.0f;
-
1399 m.m[3][0] = -(left + right) / width;
executed (the execution status of this line is deduced): m.m[3][0] = -(left + right) / width;
-
1400 m.m[0][1] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][1] = 0.0f;
-
1401 m.m[1][1] = 2.0f / invheight;
executed (the execution status of this line is deduced): m.m[1][1] = 2.0f / invheight;
-
1402 m.m[2][1] = 0.0f;
executed (the execution status of this line is deduced): m.m[2][1] = 0.0f;
-
1403 m.m[3][1] = -(top + bottom) / invheight;
executed (the execution status of this line is deduced): m.m[3][1] = -(top + bottom) / invheight;
-
1404 m.m[0][2] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][2] = 0.0f;
-
1405 m.m[1][2] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][2] = 0.0f;
-
1406 m.m[2][2] = -2.0f / clip;
executed (the execution status of this line is deduced): m.m[2][2] = -2.0f / clip;
-
1407 m.m[3][2] = -(nearPlane + farPlane) / clip;
executed (the execution status of this line is deduced): m.m[3][2] = -(nearPlane + farPlane) / clip;
-
1408 m.m[0][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][3] = 0.0f;
-
1409 m.m[1][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][3] = 0.0f;
-
1410 m.m[2][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[2][3] = 0.0f;
-
1411 m.m[3][3] = 1.0f;
executed (the execution status of this line is deduced): m.m[3][3] = 1.0f;
-
1412 m.flagBits = Translation | Scale;
executed (the execution status of this line is deduced): m.flagBits = Translation | Scale;
-
1413 -
1414 // Apply the projection. -
1415 *this *= m;
executed (the execution status of this line is deduced): *this *= m;
-
1416}
executed: }
Execution Count:4
4
1417 -
1418/*! -
1419 Multiplies this matrix by another that applies a perspective -
1420 frustum projection for a window with lower-left corner (\a left, \a bottom), -
1421 upper-right corner (\a right, \a top), and the specified \a nearPlane -
1422 and \a farPlane clipping planes. -
1423 -
1424 \sa ortho(), perspective() -
1425*/ -
1426void QMatrix4x4::frustum(float left, float right, float bottom, float top, float nearPlane, float farPlane) -
1427{ -
1428 // Bail out if the projection volume is zero-sized. -
1429 if (left == right || bottom == top || nearPlane == farPlane)
evaluated: left == right
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
evaluated: bottom == top
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
evaluated: nearPlane == farPlane
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-3
1430 return;
executed: return;
Execution Count:3
3
1431 -
1432 // Construct the projection. -
1433 QMatrix4x4 m(1);
executed (the execution status of this line is deduced): QMatrix4x4 m(1);
-
1434 float width = right - left;
executed (the execution status of this line is deduced): float width = right - left;
-
1435 float invheight = top - bottom;
executed (the execution status of this line is deduced): float invheight = top - bottom;
-
1436 float clip = farPlane - nearPlane;
executed (the execution status of this line is deduced): float clip = farPlane - nearPlane;
-
1437 m.m[0][0] = 2.0f * nearPlane / width;
executed (the execution status of this line is deduced): m.m[0][0] = 2.0f * nearPlane / width;
-
1438 m.m[1][0] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][0] = 0.0f;
-
1439 m.m[2][0] = (left + right) / width;
executed (the execution status of this line is deduced): m.m[2][0] = (left + right) / width;
-
1440 m.m[3][0] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][0] = 0.0f;
-
1441 m.m[0][1] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][1] = 0.0f;
-
1442 m.m[1][1] = 2.0f * nearPlane / invheight;
executed (the execution status of this line is deduced): m.m[1][1] = 2.0f * nearPlane / invheight;
-
1443 m.m[2][1] = (top + bottom) / invheight;
executed (the execution status of this line is deduced): m.m[2][1] = (top + bottom) / invheight;
-
1444 m.m[3][1] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][1] = 0.0f;
-
1445 m.m[0][2] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][2] = 0.0f;
-
1446 m.m[1][2] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][2] = 0.0f;
-
1447 m.m[2][2] = -(nearPlane + farPlane) / clip;
executed (the execution status of this line is deduced): m.m[2][2] = -(nearPlane + farPlane) / clip;
-
1448 m.m[3][2] = -2.0f * nearPlane * farPlane / clip;
executed (the execution status of this line is deduced): m.m[3][2] = -2.0f * nearPlane * farPlane / clip;
-
1449 m.m[0][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][3] = 0.0f;
-
1450 m.m[1][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][3] = 0.0f;
-
1451 m.m[2][3] = -1.0f;
executed (the execution status of this line is deduced): m.m[2][3] = -1.0f;
-
1452 m.m[3][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][3] = 0.0f;
-
1453 m.flagBits = General;
executed (the execution status of this line is deduced): m.flagBits = General;
-
1454 -
1455 // Apply the projection. -
1456 *this *= m;
executed (the execution status of this line is deduced): *this *= m;
-
1457}
executed: }
Execution Count:1
1
1458 -
1459/*! -
1460 Multiplies this matrix by another that applies a perspective -
1461 projection. The vertical field of view will be \a verticalAngle degrees -
1462 within a window with a given \a aspectRatio that determines the horizontal -
1463 field of view. -
1464 The projection will have the specified \a nearPlane and \a farPlane clipping -
1465 planes which are the distances from the viewer to the corresponding planes. -
1466 -
1467 \sa ortho(), frustum() -
1468*/ -
1469void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearPlane, float farPlane) -
1470{ -
1471 // Bail out if the projection volume is zero-sized. -
1472 if (nearPlane == farPlane || aspectRatio == 0.0f)
evaluated: nearPlane == farPlane
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
evaluated: aspectRatio == 0.0f
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-3
1473 return;
executed: return;
Execution Count:2
2
1474 -
1475 // Construct the projection. -
1476 QMatrix4x4 m(1);
executed (the execution status of this line is deduced): QMatrix4x4 m(1);
-
1477 float radians = (verticalAngle / 2.0f) * M_PI / 180.0f;
executed (the execution status of this line is deduced): float radians = (verticalAngle / 2.0f) * 3.14159265358979323846 / 180.0f;
-
1478 float sine = sinf(radians);
executed (the execution status of this line is deduced): float sine = sinf(radians);
-
1479 if (sine == 0.0f)
evaluated: sine == 0.0f
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1480 return;
executed: return;
Execution Count:1
1
1481 float cotan = cosf(radians) / sine;
executed (the execution status of this line is deduced): float cotan = cosf(radians) / sine;
-
1482 float clip = farPlane - nearPlane;
executed (the execution status of this line is deduced): float clip = farPlane - nearPlane;
-
1483 m.m[0][0] = cotan / aspectRatio;
executed (the execution status of this line is deduced): m.m[0][0] = cotan / aspectRatio;
-
1484 m.m[1][0] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][0] = 0.0f;
-
1485 m.m[2][0] = 0.0f;
executed (the execution status of this line is deduced): m.m[2][0] = 0.0f;
-
1486 m.m[3][0] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][0] = 0.0f;
-
1487 m.m[0][1] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][1] = 0.0f;
-
1488 m.m[1][1] = cotan;
executed (the execution status of this line is deduced): m.m[1][1] = cotan;
-
1489 m.m[2][1] = 0.0f;
executed (the execution status of this line is deduced): m.m[2][1] = 0.0f;
-
1490 m.m[3][1] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][1] = 0.0f;
-
1491 m.m[0][2] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][2] = 0.0f;
-
1492 m.m[1][2] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][2] = 0.0f;
-
1493 m.m[2][2] = -(nearPlane + farPlane) / clip;
executed (the execution status of this line is deduced): m.m[2][2] = -(nearPlane + farPlane) / clip;
-
1494 m.m[3][2] = -(2.0f * nearPlane * farPlane) / clip;
executed (the execution status of this line is deduced): m.m[3][2] = -(2.0f * nearPlane * farPlane) / clip;
-
1495 m.m[0][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[0][3] = 0.0f;
-
1496 m.m[1][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[1][3] = 0.0f;
-
1497 m.m[2][3] = -1.0f;
executed (the execution status of this line is deduced): m.m[2][3] = -1.0f;
-
1498 m.m[3][3] = 0.0f;
executed (the execution status of this line is deduced): m.m[3][3] = 0.0f;
-
1499 m.flagBits = General;
executed (the execution status of this line is deduced): m.flagBits = General;
-
1500 -
1501 // Apply the projection. -
1502 *this *= m;
executed (the execution status of this line is deduced): *this *= m;
-
1503}
executed: }
Execution Count:1
1
1504 -
1505#ifndef QT_NO_VECTOR3D -
1506 -
1507/*! -
1508 Multiplies this matrix by another that applies an \a eye position -
1509 transformation. The \a center value indicates the center of the -
1510 view that the \a eye is looking at. The \a up value indicates -
1511 which direction should be considered up with respect to the \a eye. -
1512*/ -
1513void QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up) -
1514{ -
1515 QVector3D forward = (center - eye).normalized();
never executed (the execution status of this line is deduced): QVector3D forward = (center - eye).normalized();
-
1516 QVector3D side = QVector3D::crossProduct(forward, up).normalized();
never executed (the execution status of this line is deduced): QVector3D side = QVector3D::crossProduct(forward, up).normalized();
-
1517 QVector3D upVector = QVector3D::crossProduct(side, forward);
never executed (the execution status of this line is deduced): QVector3D upVector = QVector3D::crossProduct(side, forward);
-
1518 -
1519 QMatrix4x4 m(1);
never executed (the execution status of this line is deduced): QMatrix4x4 m(1);
-
1520 m.m[0][0] = side.x();
never executed (the execution status of this line is deduced): m.m[0][0] = side.x();
-
1521 m.m[1][0] = side.y();
never executed (the execution status of this line is deduced): m.m[1][0] = side.y();
-
1522 m.m[2][0] = side.z();
never executed (the execution status of this line is deduced): m.m[2][0] = side.z();
-
1523 m.m[3][0] = 0.0f;
never executed (the execution status of this line is deduced): m.m[3][0] = 0.0f;
-
1524 m.m[0][1] = upVector.x();
never executed (the execution status of this line is deduced): m.m[0][1] = upVector.x();
-
1525 m.m[1][1] = upVector.y();
never executed (the execution status of this line is deduced): m.m[1][1] = upVector.y();
-
1526 m.m[2][1] = upVector.z();
never executed (the execution status of this line is deduced): m.m[2][1] = upVector.z();
-
1527 m.m[3][1] = 0.0f;
never executed (the execution status of this line is deduced): m.m[3][1] = 0.0f;
-
1528 m.m[0][2] = -forward.x();
never executed (the execution status of this line is deduced): m.m[0][2] = -forward.x();
-
1529 m.m[1][2] = -forward.y();
never executed (the execution status of this line is deduced): m.m[1][2] = -forward.y();
-
1530 m.m[2][2] = -forward.z();
never executed (the execution status of this line is deduced): m.m[2][2] = -forward.z();
-
1531 m.m[3][2] = 0.0f;
never executed (the execution status of this line is deduced): m.m[3][2] = 0.0f;
-
1532 m.m[0][3] = 0.0f;
never executed (the execution status of this line is deduced): m.m[0][3] = 0.0f;
-
1533 m.m[1][3] = 0.0f;
never executed (the execution status of this line is deduced): m.m[1][3] = 0.0f;
-
1534 m.m[2][3] = 0.0f;
never executed (the execution status of this line is deduced): m.m[2][3] = 0.0f;
-
1535 m.m[3][3] = 1.0f;
never executed (the execution status of this line is deduced): m.m[3][3] = 1.0f;
-
1536 m.flagBits = Rotation;
never executed (the execution status of this line is deduced): m.flagBits = Rotation;
-
1537 -
1538 *this *= m;
never executed (the execution status of this line is deduced): *this *= m;
-
1539 translate(-eye);
never executed (the execution status of this line is deduced): translate(-eye);
-
1540}
never executed: }
0
1541 -
1542#endif -
1543 -
1544/*! -
1545 \deprecated -
1546 -
1547 Flips between right-handed and left-handed coordinate systems -
1548 by multiplying the y and z co-ordinates by -1. This is normally -
1549 used to create a left-handed orthographic view without scaling -
1550 the viewport as ortho() does. -
1551 -
1552 \sa ortho() -
1553*/ -
1554void QMatrix4x4::flipCoordinates() -
1555{ -
1556 // Multiplying the y and z coordinates with -1 does NOT flip between right-handed and -
1557 // left-handed coordinate systems, it just rotates 180 degrees around the x axis, so -
1558 // I'm deprecating this function. -
1559 if (flagBits < Rotation2D) {
evaluated: flagBits < Rotation2D
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
1560 // Translation | Scale -
1561 m[1][1] = -m[1][1];
executed (the execution status of this line is deduced): m[1][1] = -m[1][1];
-
1562 m[2][2] = -m[2][2];
executed (the execution status of this line is deduced): m[2][2] = -m[2][2];
-
1563 } else {
executed: }
Execution Count:3
3
1564 m[1][0] = -m[1][0];
executed (the execution status of this line is deduced): m[1][0] = -m[1][0];
-
1565 m[1][1] = -m[1][1];
executed (the execution status of this line is deduced): m[1][1] = -m[1][1];
-
1566 m[1][2] = -m[1][2];
executed (the execution status of this line is deduced): m[1][2] = -m[1][2];
-
1567 m[1][3] = -m[1][3];
executed (the execution status of this line is deduced): m[1][3] = -m[1][3];
-
1568 m[2][0] = -m[2][0];
executed (the execution status of this line is deduced): m[2][0] = -m[2][0];
-
1569 m[2][1] = -m[2][1];
executed (the execution status of this line is deduced): m[2][1] = -m[2][1];
-
1570 m[2][2] = -m[2][2];
executed (the execution status of this line is deduced): m[2][2] = -m[2][2];
-
1571 m[2][3] = -m[2][3];
executed (the execution status of this line is deduced): m[2][3] = -m[2][3];
-
1572 }
executed: }
Execution Count:1
1
1573 flagBits |= Scale;
executed (the execution status of this line is deduced): flagBits |= Scale;
-
1574}
executed: }
Execution Count:4
4
1575 -
1576/*! -
1577 Retrieves the 16 items in this matrix and copies them to \a values -
1578 in row-major order. -
1579*/ -
1580void QMatrix4x4::copyDataTo(float *values) const -
1581{ -
1582 for (int row = 0; row < 4; ++row)
evaluated: row < 4
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
1583 for (int col = 0; col < 4; ++col)
evaluated: col < 4
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:4
4-16
1584 values[row * 4 + col] = float(m[col][row]);
executed: values[row * 4 + col] = float(m[col][row]);
Execution Count:16
16
1585}
executed: }
Execution Count:1
1
1586 -
1587/*! -
1588 Returns the conventional Qt 2D affine transformation matrix that -
1589 corresponds to this matrix. It is assumed that this matrix -
1590 only contains 2D affine transformation elements. -
1591 -
1592 \sa toTransform() -
1593*/ -
1594QMatrix QMatrix4x4::toAffine() const -
1595{ -
1596 return QMatrix(m[0][0], m[0][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
1597 m[1][0], m[1][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
1598 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
1599} -
1600 -
1601/*! -
1602 Returns the conventional Qt 2D transformation matrix that -
1603 corresponds to this matrix. -
1604 -
1605 The returned QTransform is formed by simply dropping the -
1606 third row and third column of the QMatrix4x4. This is suitable -
1607 for implementing orthographic projections where the z co-ordinate -
1608 should be dropped rather than projected. -
1609 -
1610 \sa toAffine() -
1611*/ -
1612QTransform QMatrix4x4::toTransform() const -
1613{ -
1614 return QTransform(m[0][0], m[0][1], m[0][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
1615 m[1][0], m[1][1], m[1][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
1616 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
1617} -
1618 -
1619/*! -
1620 Returns the conventional Qt 2D transformation matrix that -
1621 corresponds to this matrix. -
1622 -
1623 If \a distanceToPlane is non-zero, it indicates a projection -
1624 factor to use to adjust for the z co-ordinate. The value of -
1625 1024 corresponds to the projection factor used -
1626 by QTransform::rotate() for the x and y axes. -
1627 -
1628 If \a distanceToPlane is zero, then the returned QTransform -
1629 is formed by simply dropping the third row and third column -
1630 of the QMatrix4x4. This is suitable for implementing -
1631 orthographic projections where the z co-ordinate should -
1632 be dropped rather than projected. -
1633 -
1634 \sa toAffine() -
1635*/ -
1636QTransform QMatrix4x4::toTransform(float distanceToPlane) const -
1637{ -
1638 if (distanceToPlane == 1024.0f) {
partially evaluated: distanceToPlane == 1024.0f
TRUEFALSE
yes
Evaluation Count:1805
no
Evaluation Count:0
0-1805
1639 // Optimize the common case with constants. -
1640 return QTransform(m[0][0], m[0][1], m[0][3] - m[0][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
1641 m[1][0], m[1][1], m[1][3] - m[1][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
1642 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
1643 } else if (distanceToPlane != 0.0f) {
never evaluated: distanceToPlane != 0.0f
0
1644 // The following projection matrix is pre-multiplied with "matrix": -
1645 // | 1 0 0 0 | -
1646 // | 0 1 0 0 | -
1647 // | 0 0 1 0 | -
1648 // | 0 0 d 1 | -
1649 // where d = -1 / distanceToPlane. After projection, row 3 and -
1650 // column 3 are dropped to form the final QTransform. -
1651 float d = 1.0f / distanceToPlane;
never executed (the execution status of this line is deduced): float d = 1.0f / distanceToPlane;
-
1652 return QTransform(m[0][0], m[0][1], m[0][3] - m[0][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
1653 m[1][0], m[1][1], m[1][3] - m[1][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
1654 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
1655 } else { -
1656 // Orthographic projection: drop row 3 and column 3. -
1657 return QTransform(m[0][0], m[0][1], m[0][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
1658 m[1][0], m[1][1], m[1][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
1659 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
1660 } -
1661} -
1662 -
1663/*! -
1664 \fn QPoint QMatrix4x4::map(const QPoint& point) const -
1665 -
1666 Maps \a point by multiplying this matrix by \a point. -
1667 -
1668 \sa mapRect() -
1669*/ -
1670 -
1671/*! -
1672 \fn QPointF QMatrix4x4::map(const QPointF& point) const -
1673 -
1674 Maps \a point by multiplying this matrix by \a point. -
1675 -
1676 \sa mapRect() -
1677*/ -
1678 -
1679#ifndef QT_NO_VECTOR3D -
1680 -
1681/*! -
1682 \fn QVector3D QMatrix4x4::map(const QVector3D& point) const -
1683 -
1684 Maps \a point by multiplying this matrix by \a point. -
1685 -
1686 \sa mapRect(), mapVector() -
1687*/ -
1688 -
1689/*! -
1690 \fn QVector3D QMatrix4x4::mapVector(const QVector3D& vector) const -
1691 -
1692 Maps \a vector by multiplying the top 3x3 portion of this matrix -
1693 by \a vector. The translation and projection components of -
1694 this matrix are ignored. -
1695 -
1696 \sa map() -
1697*/ -
1698 -
1699#endif -
1700 -
1701#ifndef QT_NO_VECTOR4D -
1702 -
1703/*! -
1704 \fn QVector4D QMatrix4x4::map(const QVector4D& point) const; -
1705 -
1706 Maps \a point by multiplying this matrix by \a point. -
1707 -
1708 \sa mapRect() -
1709*/ -
1710 -
1711#endif -
1712 -
1713/*! -
1714 Maps \a rect by multiplying this matrix by the corners -
1715 of \a rect and then forming a new rectangle from the results. -
1716 The returned rectangle will be an ordinary 2D rectangle -
1717 with sides parallel to the horizontal and vertical axes. -
1718 -
1719 \sa map() -
1720*/ -
1721QRect QMatrix4x4::mapRect(const QRect& rect) const -
1722{ -
1723 if (flagBits < Scale) {
evaluated: flagBits < Scale
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6
4-6
1724 // Translation -
1725 return QRect(qRound(rect.x() + m[3][0]),
executed: return QRect(qRound(rect.x() + m[3][0]), qRound(rect.y() + m[3][1]), rect.width(), rect.height());
Execution Count:4
4
1726 qRound(rect.y() + m[3][1]),
executed: return QRect(qRound(rect.x() + m[3][0]), qRound(rect.y() + m[3][1]), rect.width(), rect.height());
Execution Count:4
4
1727 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
1728 } else if (flagBits < Rotation2D) {
evaluated: flagBits < Rotation2D
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
1729 // Translation | Scale -
1730 float x = rect.x() * m[0][0] + m[3][0];
executed (the execution status of this line is deduced): float x = rect.x() * m[0][0] + m[3][0];
-
1731 float y = rect.y() * m[1][1] + m[3][1];
executed (the execution status of this line is deduced): float y = rect.y() * m[1][1] + m[3][1];
-
1732 float w = rect.width() * m[0][0];
executed (the execution status of this line is deduced): float w = rect.width() * m[0][0];
-
1733 float h = rect.height() * m[1][1];
executed (the execution status of this line is deduced): float h = rect.height() * m[1][1];
-
1734 if (w < 0) {
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1735 w = -w;
executed (the execution status of this line is deduced): w = -w;
-
1736 x -= w;
executed (the execution status of this line is deduced): x -= w;
-
1737 }
executed: }
Execution Count:2
2
1738 if (h < 0) {
partially evaluated: h < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1739 h = -h;
never executed (the execution status of this line is deduced): h = -h;
-
1740 y -= h;
never executed (the execution status of this line is deduced): y -= h;
-
1741 }
never executed: }
0
1742 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
1743 } -
1744 -
1745 QPoint tl = map(rect.topLeft());
executed (the execution status of this line is deduced): QPoint tl = map(rect.topLeft());
-
1746 QPoint tr = map(QPoint(rect.x() + rect.width(), rect.y()));
executed (the execution status of this line is deduced): QPoint tr = map(QPoint(rect.x() + rect.width(), rect.y()));
-
1747 QPoint bl = map(QPoint(rect.x(), rect.y() + rect.height()));
executed (the execution status of this line is deduced): QPoint bl = map(QPoint(rect.x(), rect.y() + rect.height()));
-
1748 QPoint br = map(QPoint(rect.x() + rect.width(),
executed (the execution status of this line is deduced): QPoint br = map(QPoint(rect.x() + rect.width(),
-
1749 rect.y() + rect.height()));
executed (the execution status of this line is deduced): rect.y() + rect.height()));
-
1750 -
1751 int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));
executed (the execution status of this line is deduced): int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));
-
1752 int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));
executed (the execution status of this line is deduced): int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));
-
1753 int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));
executed (the execution status of this line is deduced): int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));
-
1754 int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));
executed (the execution status of this line is deduced): int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));
-
1755 -
1756 return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
executed: return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
Execution Count:2
2
1757} -
1758 -
1759/*! -
1760 Maps \a rect by multiplying this matrix by the corners -
1761 of \a rect and then forming a new rectangle from the results. -
1762 The returned rectangle will be an ordinary 2D rectangle -
1763 with sides parallel to the horizontal and vertical axes. -
1764 -
1765 \sa map() -
1766*/ -
1767QRectF QMatrix4x4::mapRect(const QRectF& rect) const -
1768{ -
1769 if (flagBits < Scale) {
evaluated: flagBits < Scale
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6
4-6
1770 // Translation -
1771 return rect.translated(m[3][0], m[3][1]);
executed: return rect.translated(m[3][0], m[3][1]);
Execution Count:4
4
1772 } else if (flagBits < Rotation2D) {
evaluated: flagBits < Rotation2D
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
1773 // Translation | Scale -
1774 float x = rect.x() * m[0][0] + m[3][0];
executed (the execution status of this line is deduced): float x = rect.x() * m[0][0] + m[3][0];
-
1775 float y = rect.y() * m[1][1] + m[3][1];
executed (the execution status of this line is deduced): float y = rect.y() * m[1][1] + m[3][1];
-
1776 float w = rect.width() * m[0][0];
executed (the execution status of this line is deduced): float w = rect.width() * m[0][0];
-
1777 float h = rect.height() * m[1][1];
executed (the execution status of this line is deduced): float h = rect.height() * m[1][1];
-
1778 if (w < 0) {
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1779 w = -w;
executed (the execution status of this line is deduced): w = -w;
-
1780 x -= w;
executed (the execution status of this line is deduced): x -= w;
-
1781 }
executed: }
Execution Count:2
2
1782 if (h < 0) {
partially evaluated: h < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1783 h = -h;
never executed (the execution status of this line is deduced): h = -h;
-
1784 y -= h;
never executed (the execution status of this line is deduced): y -= h;
-
1785 }
never executed: }
0
1786 return QRectF(x, y, w, h);
executed: return QRectF(x, y, w, h);
Execution Count:4
4
1787 } -
1788 -
1789 QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight());
executed (the execution status of this line is deduced): QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight());
-
1790 QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight());
executed (the execution status of this line is deduced): QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight());
-
1791 -
1792 float xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));
executed (the execution status of this line is deduced): float xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));
-
1793 float xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));
executed (the execution status of this line is deduced): float xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));
-
1794 float ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));
executed (the execution status of this line is deduced): float ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));
-
1795 float ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));
executed (the execution status of this line is deduced): float ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));
-
1796 -
1797 return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
executed: return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
Execution Count:2
2
1798} -
1799 -
1800/*! -
1801 \fn float *QMatrix4x4::data() -
1802 -
1803 Returns a pointer to the raw data of this matrix. -
1804 -
1805 \sa constData(), optimize() -
1806*/ -
1807 -
1808/*! -
1809 \fn const float *QMatrix4x4::data() const -
1810 -
1811 Returns a constant pointer to the raw data of this matrix. -
1812 This raw data is stored in column-major format. -
1813 -
1814 \sa constData() -
1815*/ -
1816 -
1817/*! -
1818 \fn const float *QMatrix4x4::constData() const -
1819 -
1820 Returns a constant pointer to the raw data of this matrix. -
1821 This raw data is stored in column-major format. -
1822 -
1823 \sa data() -
1824*/ -
1825 -
1826// Helper routine for inverting orthonormal matrices that consist -
1827// of just rotations and translations. -
1828QMatrix4x4 QMatrix4x4::orthonormalInverse() const -
1829{ -
1830 QMatrix4x4 result(1); // The '1' says not to load identity
executed (the execution status of this line is deduced): QMatrix4x4 result(1);
-
1831 -
1832 result.m[0][0] = m[0][0];
executed (the execution status of this line is deduced): result.m[0][0] = m[0][0];
-
1833 result.m[1][0] = m[0][1];
executed (the execution status of this line is deduced): result.m[1][0] = m[0][1];
-
1834 result.m[2][0] = m[0][2];
executed (the execution status of this line is deduced): result.m[2][0] = m[0][2];
-
1835 -
1836 result.m[0][1] = m[1][0];
executed (the execution status of this line is deduced): result.m[0][1] = m[1][0];
-
1837 result.m[1][1] = m[1][1];
executed (the execution status of this line is deduced): result.m[1][1] = m[1][1];
-
1838 result.m[2][1] = m[1][2];
executed (the execution status of this line is deduced): result.m[2][1] = m[1][2];
-
1839 -
1840 result.m[0][2] = m[2][0];
executed (the execution status of this line is deduced): result.m[0][2] = m[2][0];
-
1841 result.m[1][2] = m[2][1];
executed (the execution status of this line is deduced): result.m[1][2] = m[2][1];
-
1842 result.m[2][2] = m[2][2];
executed (the execution status of this line is deduced): result.m[2][2] = m[2][2];
-
1843 -
1844 result.m[0][3] = 0.0f;
executed (the execution status of this line is deduced): result.m[0][3] = 0.0f;
-
1845 result.m[1][3] = 0.0f;
executed (the execution status of this line is deduced): result.m[1][3] = 0.0f;
-
1846 result.m[2][3] = 0.0f;
executed (the execution status of this line is deduced): result.m[2][3] = 0.0f;
-
1847 -
1848 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]);
executed (the execution status of this line is deduced): 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]);
-
1849 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]);
executed (the execution status of this line is deduced): 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]);
-
1850 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]);
executed (the execution status of this line is deduced): 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]);
-
1851 result.m[3][3] = 1.0f;
executed (the execution status of this line is deduced): result.m[3][3] = 1.0f;
-
1852 -
1853 result.flagBits = flagBits;
executed (the execution status of this line is deduced): result.flagBits = flagBits;
-
1854 -
1855 return result;
executed: return result;
Execution Count:2
2
1856} -
1857 -
1858/*! -
1859 Optimize the usage of this matrix from its current elements. -
1860 -
1861 Some operations such as translate(), scale(), and rotate() can be -
1862 performed more efficiently if the matrix being modified is already -
1863 known to be the identity, a previous translate(), a previous -
1864 scale(), etc. -
1865 -
1866 Normally the QMatrix4x4 class keeps track of this special type internally -
1867 as operations are performed. However, if the matrix is modified -
1868 directly with operator()() or data(), then QMatrix4x4 will lose track of -
1869 the special type and will revert to the safest but least efficient -
1870 operations thereafter. -
1871 -
1872 By calling optimize() after directly modifying the matrix, -
1873 the programmer can force QMatrix4x4 to recover the special type if -
1874 the elements appear to conform to one of the known optimized types. -
1875 -
1876 \sa operator()(), data(), translate() -
1877*/ -
1878void QMatrix4x4::optimize() -
1879{ -
1880 // If the last row is not (0, 0, 0, 1), the matrix is not a special type. -
1881 flagBits = General;
executed (the execution status of this line is deduced): flagBits = General;
-
1882 if (m[0][3] != 0 || m[1][3] != 0 || m[2][3] != 0 || m[3][3] != 1)
evaluated: m[0][3] != 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:32
partially evaluated: m[1][3] != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
partially evaluated: m[2][3] != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
evaluated: m[3][3] != 1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:29
0-32
1883 return;
executed: return;
Execution Count:8
8
1884 -
1885 flagBits &= ~Perspective;
executed (the execution status of this line is deduced): flagBits &= ~Perspective;
-
1886 -
1887 // If the last column is (0, 0, 0, 1), then there is no translation. -
1888 if (m[3][0] == 0 && m[3][1] == 0 && m[3][2] == 0)
evaluated: m[3][0] == 0
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:14
partially evaluated: m[3][1] == 0
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
partially evaluated: m[3][2] == 0
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
1889 flagBits &= ~Translation;
executed: flagBits &= ~Translation;
Execution Count:15
15
1890 -
1891 // If the two first elements of row 3 and column 3 are 0, then any rotation must be about Z. -
1892 if (!m[0][2] && !m[1][2] && !m[2][0] && !m[2][1]) {
evaluated: !m[0][2]
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:2
evaluated: !m[1][2]
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:1
partially evaluated: !m[2][0]
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
partially evaluated: !m[2][1]
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-27
1893 flagBits &= ~Rotation;
executed (the execution status of this line is deduced): flagBits &= ~Rotation;
-
1894 // If the six non-diagonal elements in the top left 3x3 matrix are 0, there is no rotation. -
1895 if (!m[0][1] && !m[1][0]) {
evaluated: !m[0][1]
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:5
partially evaluated: !m[1][0]
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
1896 flagBits &= ~Rotation2D;
executed (the execution status of this line is deduced): flagBits &= ~Rotation2D;
-
1897 // Check for identity. -
1898 if (m[0][0] == 1 && m[1][1] == 1 && m[2][2] == 1)
evaluated: m[0][0] == 1
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:11
evaluated: m[1][1] == 1
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
partially evaluated: m[2][2] == 1
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-11
1899 flagBits &= ~Scale;
executed: flagBits &= ~Scale;
Execution Count:9
9
1900 } else {
executed: }
Execution Count:21
21
1901 // If the columns are orthonormal and form a right-handed system, then there is no scale. -
1902 double mm[4][4];
executed (the execution status of this line is deduced): double mm[4][4];
-
1903 copyToDoubles(m, mm);
executed (the execution status of this line is deduced): copyToDoubles(m, mm);
-
1904 double det = matrixDet2(mm, 0, 1, 0, 1);
executed (the execution status of this line is deduced): double det = matrixDet2(mm, 0, 1, 0, 1);
-
1905 double lenX = mm[0][0] * mm[0][0] + mm[0][1] * mm[0][1];
executed (the execution status of this line is deduced): double lenX = mm[0][0] * mm[0][0] + mm[0][1] * mm[0][1];
-
1906 double lenY = mm[1][0] * mm[1][0] + mm[1][1] * mm[1][1];
executed (the execution status of this line is deduced): double lenY = mm[1][0] * mm[1][0] + mm[1][1] * mm[1][1];
-
1907 double lenZ = mm[2][2];
executed (the execution status of this line is deduced): double lenZ = mm[2][2];
-
1908 if (qFuzzyCompare(det, 1.0) && qFuzzyCompare(lenX, 1.0)
evaluated: qFuzzyCompare(det, 1.0)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
partially evaluated: qFuzzyCompare(lenX, 1.0)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-3
1909 && qFuzzyCompare(lenY, 1.0) && qFuzzyCompare(lenZ, 1.0))
partially evaluated: qFuzzyCompare(lenY, 1.0)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: qFuzzyCompare(lenZ, 1.0)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1910 { -
1911 flagBits &= ~Scale;
executed (the execution status of this line is deduced): flagBits &= ~Scale;
-
1912 }
executed: }
Execution Count:2
2
1913 }
executed: }
Execution Count:5
5
1914 } else { -
1915 // If the columns are orthonormal and form a right-handed system, then there is no scale. -
1916 double mm[4][4];
executed (the execution status of this line is deduced): double mm[4][4];
-
1917 copyToDoubles(m, mm);
executed (the execution status of this line is deduced): copyToDoubles(m, mm);
-
1918 double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);
executed (the execution status of this line is deduced): double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);
-
1919 double lenX = mm[0][0] * mm[0][0] + mm[0][1] * mm[0][1] + mm[0][2] * mm[0][2];
executed (the execution status of this line is deduced): double lenX = mm[0][0] * mm[0][0] + mm[0][1] * mm[0][1] + mm[0][2] * mm[0][2];
-
1920 double lenY = mm[1][0] * mm[1][0] + mm[1][1] * mm[1][1] + mm[1][2] * mm[1][2];
executed (the execution status of this line is deduced): double lenY = mm[1][0] * mm[1][0] + mm[1][1] * mm[1][1] + mm[1][2] * mm[1][2];
-
1921 double lenZ = mm[2][0] * mm[2][0] + mm[2][1] * mm[2][1] + mm[2][2] * mm[2][2];
executed (the execution status of this line is deduced): double lenZ = mm[2][0] * mm[2][0] + mm[2][1] * mm[2][1] + mm[2][2] * mm[2][2];
-
1922 if (qFuzzyCompare(det, 1.0) && qFuzzyCompare(lenX, 1.0)
evaluated: qFuzzyCompare(det, 1.0)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
partially evaluated: qFuzzyCompare(lenX, 1.0)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-2
1923 && qFuzzyCompare(lenY, 1.0) && qFuzzyCompare(lenZ, 1.0))
partially evaluated: qFuzzyCompare(lenY, 1.0)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: qFuzzyCompare(lenZ, 1.0)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1924 { -
1925 flagBits &= ~Scale;
executed (the execution status of this line is deduced): flagBits &= ~Scale;
-
1926 }
executed: }
Execution Count:1
1
1927 }
executed: }
Execution Count:3
3
1928} -
1929 -
1930/*! -
1931 Returns the matrix as a QVariant. -
1932*/ -
1933QMatrix4x4::operator QVariant() const -
1934{ -
1935 return QVariant(QVariant::Matrix4x4, this);
executed: return QVariant(QVariant::Matrix4x4, this);
Execution Count:1
1
1936} -
1937 -
1938#ifndef QT_NO_DEBUG_STREAM -
1939 -
1940QDebug operator<<(QDebug dbg, const QMatrix4x4 &m) -
1941{ -
1942 // Create a string that represents the matrix type. -
1943 QByteArray bits;
never executed (the execution status of this line is deduced): QByteArray bits;
-
1944 if (m.flagBits == QMatrix4x4::Identity) {
partially evaluated: m.flagBits == QMatrix4x4::Identity
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1945 bits = "Identity";
executed (the execution status of this line is deduced): bits = "Identity";
-
1946 } else if (m.flagBits == QMatrix4x4::General) {
executed: }
Execution Count:1
never evaluated: m.flagBits == QMatrix4x4::General
0-1
1947 bits = "General";
never executed (the execution status of this line is deduced): bits = "General";
-
1948 } else {
never executed: }
0
1949 if ((m.flagBits & QMatrix4x4::Translation) != 0)
never evaluated: (m.flagBits & QMatrix4x4::Translation) != 0
0
1950 bits += "Translation,";
never executed: bits += "Translation,";
0
1951 if ((m.flagBits & QMatrix4x4::Scale) != 0)
never evaluated: (m.flagBits & QMatrix4x4::Scale) != 0
0
1952 bits += "Scale,";
never executed: bits += "Scale,";
0
1953 if ((m.flagBits & QMatrix4x4::Rotation2D) != 0)
never evaluated: (m.flagBits & QMatrix4x4::Rotation2D) != 0
0
1954 bits += "Rotation2D,";
never executed: bits += "Rotation2D,";
0
1955 if ((m.flagBits & QMatrix4x4::Rotation) != 0)
never evaluated: (m.flagBits & QMatrix4x4::Rotation) != 0
0
1956 bits += "Rotation,";
never executed: bits += "Rotation,";
0
1957 if ((m.flagBits & QMatrix4x4::Perspective) != 0)
never evaluated: (m.flagBits & QMatrix4x4::Perspective) != 0
0
1958 bits += "Perspective,";
never executed: bits += "Perspective,";
0
1959 if (bits.size() > 0)
never evaluated: bits.size() > 0
0
1960 bits = bits.left(bits.size() - 1);
never executed: bits = bits.left(bits.size() - 1);
0
1961 }
never executed: }
0
1962 -
1963 // Output in row-major order because it is more human-readable. -
1964 dbg.nospace() << "QMatrix4x4(type:" << bits.constData() << endl
executed (the execution status of this line is deduced): dbg.nospace() << "QMatrix4x4(type:" << bits.constData() << endl
-
1965 << qSetFieldWidth(10)
executed (the execution status of this line is deduced): << qSetFieldWidth(10)
-
1966 << m(0, 0) << m(0, 1) << m(0, 2) << m(0, 3) << endl
executed (the execution status of this line is deduced): << m(0, 0) << m(0, 1) << m(0, 2) << m(0, 3) << endl
-
1967 << m(1, 0) << m(1, 1) << m(1, 2) << m(1, 3) << endl
executed (the execution status of this line is deduced): << m(1, 0) << m(1, 1) << m(1, 2) << m(1, 3) << endl
-
1968 << m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << endl
executed (the execution status of this line is deduced): << m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << endl
-
1969 << m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << endl
executed (the execution status of this line is deduced): << m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << endl
-
1970 << qSetFieldWidth(0) << ')';
executed (the execution status of this line is deduced): << qSetFieldWidth(0) << ')';
-
1971 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
1972} -
1973 -
1974#endif -
1975 -
1976#ifndef QT_NO_DATASTREAM -
1977 -
1978/*! -
1979 \fn QDataStream &operator<<(QDataStream &stream, const QMatrix4x4 &matrix) -
1980 \relates QMatrix4x4 -
1981 -
1982 Writes the given \a matrix to the given \a stream and returns a -
1983 reference to the stream. -
1984 -
1985 \sa {Serializing Qt Data Types} -
1986*/ -
1987 -
1988QDataStream &operator<<(QDataStream &stream, const QMatrix4x4 &matrix) -
1989{ -
1990 for (int row = 0; row < 4; ++row)
never evaluated: row < 4
0
1991 for (int col = 0; col < 4; ++col)
never evaluated: col < 4
0
1992 stream << matrix(row, col);
never executed: stream << matrix(row, col);
0
1993 return stream;
never executed: return stream;
0
1994} -
1995 -
1996/*! -
1997 \fn QDataStream &operator>>(QDataStream &stream, QMatrix4x4 &matrix) -
1998 \relates QMatrix4x4 -
1999 -
2000 Reads a 4x4 matrix from the given \a stream into the given \a matrix -
2001 and returns a reference to the stream. -
2002 -
2003 \sa {Serializing Qt Data Types} -
2004*/ -
2005 -
2006QDataStream &operator>>(QDataStream &stream, QMatrix4x4 &matrix) -
2007{ -
2008 float x;
never executed (the execution status of this line is deduced): float x;
-
2009 for (int row = 0; row < 4; ++row) {
never evaluated: row < 4
0
2010 for (int col = 0; col < 4; ++col) {
never evaluated: col < 4
0
2011 stream >> x;
never executed (the execution status of this line is deduced): stream >> x;
-
2012 matrix(row, col) = x;
never executed (the execution status of this line is deduced): matrix(row, col) = x;
-
2013 }
never executed: }
0
2014 }
never executed: }
0
2015 matrix.optimize();
never executed (the execution status of this line is deduced): matrix.optimize();
-
2016 return stream;
never executed: return stream;
0
2017} -
2018 -
2019#endif // QT_NO_DATASTREAM -
2020 -
2021#endif // QT_NO_MATRIX4X4 -
2022 -
2023QT_END_NAMESPACE -
2024 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial