math3d/qvector2d.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3QVector2D::QVector2D(const QVector3D& vector) -
4{ -
5 xp = vector.xp; -
6 yp = vector.yp; -
7}
executed: }
Execution Count:1
1
8QVector2D::QVector2D(const QVector4D& vector) -
9{ -
10 xp = vector.xp; -
11 yp = vector.yp; -
12}
executed: }
Execution Count:1
1
13float QVector2D::length() const -
14{ -
15 -
16 double len = double(xp) * double(xp) + -
17 double(yp) * double(yp); -
18 return float(sqrt(len));
executed: return float(sqrt(len));
Execution Count:25
25
19} -
20 -
21 -
22 -
23 -
24 -
25 -
26 -
27float QVector2D::lengthSquared() const -
28{ -
29 return xp * xp + yp * yp;
executed: return xp * xp + yp * yp;
Execution Count:6
6
30} -
31QVector2D QVector2D::normalized() const -
32{ -
33 -
34 double len = double(xp) * double(xp) + -
35 double(yp) * double(yp); -
36 if (qFuzzyIsNull(len - 1.0f)) {
evaluated: qFuzzyIsNull(len - 1.0f)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:11
4-11
37 return *this;
executed: return *this;
Execution Count:4
4
38 } else if (!qFuzzyIsNull(len)) {
evaluated: !qFuzzyIsNull(len)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:5
5-6
39 double sqrtLen = sqrt(len); -
40 return QVector2D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen));
executed: return QVector2D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen));
Execution Count:6
6
41 } else { -
42 return QVector2D();
executed: return QVector2D();
Execution Count:5
5
43 } -
44} -
45 -
46 -
47 -
48 -
49 -
50 -
51 -
52void QVector2D::normalize() -
53{ -
54 -
55 double len = double(xp) * double(xp) + -
56 double(yp) * double(yp); -
57 if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
evaluated: qFuzzyIsNull(len - 1.0f)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
evaluated: qFuzzyIsNull(len)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-4
58 return;
executed: return;
Execution Count:5
5
59 -
60 len = sqrt(len); -
61 -
62 xp = float(double(xp) / len); -
63 yp = float(double(yp) / len); -
64}
executed: }
Execution Count:1
1
65float QVector2D::dotProduct(const QVector2D& v1, const QVector2D& v2) -
66{ -
67 return v1.xp * v2.xp + v1.yp * v2.yp;
executed: return v1.xp * v2.xp + v1.yp * v2.yp;
Execution Count:6
6
68} -
69QVector3D QVector2D::toVector3D() const -
70{ -
71 return QVector3D(xp, yp, 0.0f);
executed: return QVector3D(xp, yp, 0.0f);
Execution Count:1
1
72} -
73QVector4D QVector2D::toVector4D() const -
74{ -
75 return QVector4D(xp, yp, 0.0f, 0.0f);
executed: return QVector4D(xp, yp, 0.0f, 0.0f);
Execution Count:1
1
76} -
77QVector2D::operator QVariant() const -
78{ -
79 return QVariant(QVariant::Vector2D, this);
executed: return QVariant(QVariant::Vector2D, this);
Execution Count:1
1
80} -
81 -
82 -
83 -
84QDebug operator<<(QDebug dbg, const QVector2D &vector) -
85{ -
86 dbg.nospace() << "QVector2D(" << vector.x() << ", " << vector.y() << ')'; -
87 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
88} -
89QDataStream &operator<<(QDataStream &stream, const QVector2D &vector) -
90{ -
91 stream << vector.x() << vector.y(); -
92 return stream;
never executed: return stream;
0
93} -
94QDataStream &operator>>(QDataStream &stream, QVector2D &vector) -
95{ -
96 float x, y; -
97 stream >> x; -
98 stream >> y; -
99 vector.setX(x); -
100 vector.setY(y); -
101 return stream;
never executed: return stream;
0
102} -
103 -
104 -
105 -
106 -
107 -
108 -
109 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial