qvector2d.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/math3d/qvector2d.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3QVector2D::QVector2D(const QVector3D& vector)-
4{-
5 xp = vector.xp;-
6 yp = vector.yp;-
7}
never executed: end of block
0
8QVector2D::QVector2D(const QVector4D& vector)-
9{-
10 xp = vector.xp;-
11 yp = vector.yp;-
12}
never executed: end of block
0
13float QVector2D::length() const-
14{-
15-
16 double len = double(xp) * double(xp) +-
17 double(yp) * double(yp);-
18 return
never executed: return float(std::sqrt(len));
float(std::sqrt(len));
never executed: return float(std::sqrt(len));
0
19}-
20-
21-
22-
23-
24-
25-
26-
27float QVector2D::lengthSquared() const-
28{-
29 return
never executed: return xp * xp + yp * yp;
xp * xp + yp * yp;
never executed: return xp * xp + yp * yp;
0
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)
qFuzzyIsNull(len - 1.0f)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
37 return
never executed: return *this;
*this;
never executed: return *this;
0
38 } else if (!qFuzzyIsNull(len)
!qFuzzyIsNull(len)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
39 double sqrtLen = std::sqrt(len);-
40 return
never executed: return QVector2D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen));
QVector2D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen));
never executed: return QVector2D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen));
0
41 } else {-
42 return
never executed: return QVector2D();
QVector2D();
never executed: return QVector2D();
0
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 - 1.0f)Description
TRUEnever evaluated
FALSEnever evaluated
|| qFuzzyIsNull(len)
qFuzzyIsNull(len)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
58 return;
never executed: return;
0
59-
60 len = std::sqrt(len);-
61-
62 xp = float(double(xp) / len);-
63 yp = float(double(yp) / len);-
64}
never executed: end of block
0
65float QVector2D::distanceToPoint(const QVector2D& point) const-
66{-
67 return
never executed: return (*this - point).length();
(*this - point).length();
never executed: return (*this - point).length();
0
68}-
69float QVector2D::distanceToLine-
70 (const QVector2D& point, const QVector2D& direction) const-
71{-
72 if (direction.isNull()
direction.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
73 return
never executed: return (*this - point).length();
(*this - point).length();
never executed: return (*this - point).length();
0
74 QVector2D p = point + dotProduct(*this - point, direction) * direction;-
75 return
never executed: return (*this - p).length();
(*this - p).length();
never executed: return (*this - p).length();
0
76}-
77float QVector2D::dotProduct(const QVector2D& v1, const QVector2D& v2)-
78{-
79 return
never executed: return v1.xp * v2.xp + v1.yp * v2.yp;
v1.xp * v2.xp + v1.yp * v2.yp;
never executed: return v1.xp * v2.xp + v1.yp * v2.yp;
0
80}-
81QVector3D QVector2D::toVector3D() const-
82{-
83 return
never executed: return QVector3D(xp, yp, 0.0f);
QVector3D(xp, yp, 0.0f);
never executed: return QVector3D(xp, yp, 0.0f);
0
84}-
85QVector4D QVector2D::toVector4D() const-
86{-
87 return
never executed: return QVector4D(xp, yp, 0.0f, 0.0f);
QVector4D(xp, yp, 0.0f, 0.0f);
never executed: return QVector4D(xp, yp, 0.0f, 0.0f);
0
88}-
89QVector2D::operator QVariant() const-
90{-
91 return
never executed: return QVariant(QVariant::Vector2D, this);
QVariant(QVariant::Vector2D, this);
never executed: return QVariant(QVariant::Vector2D, this);
0
92}-
93-
94-
95-
96QDebug operator<<(QDebug dbg, const QVector2D &vector)-
97{-
98 QDebugStateSaver saver(dbg);-
99 dbg.nospace() << "QVector2D(" << vector.x() << ", " << vector.y() << ')';-
100 return
never executed: return dbg;
dbg;
never executed: return dbg;
0
101}-
102QDataStream &operator<<(QDataStream &stream, const QVector2D &vector)-
103{-
104 stream << vector.x() << vector.y();-
105 return
never executed: return stream;
stream;
never executed: return stream;
0
106}-
107QDataStream &operator>>(QDataStream &stream, QVector2D &vector)-
108{-
109 float x, y;-
110 stream >> x;-
111 stream >> y;-
112 vector.setX(x);-
113 vector.setY(y);-
114 return
never executed: return stream;
stream;
never executed: return stream;
0
115}-
116-
117-
118-
119-
120-
121-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9