qvector4d.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/math3d/qvector4d.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3QVector4D::QVector4D(const QVector2D& vector)-
4{-
5 xp = vector.xp;-
6 yp = vector.yp;-
7 zp = 0.0f;-
8 wp = 0.0f;-
9}
never executed: end of block
0
10-
11-
12-
13-
14-
15-
16-
17QVector4D::QVector4D(const QVector2D& vector, float zpos, float wpos)-
18{-
19 xp = vector.xp;-
20 yp = vector.yp;-
21 zp = zpos;-
22 wp = wpos;-
23}
never executed: end of block
0
24QVector4D::QVector4D(const QVector3D& vector)-
25{-
26 xp = vector.xp;-
27 yp = vector.yp;-
28 zp = vector.zp;-
29 wp = 0.0f;-
30}
never executed: end of block
0
31-
32-
33-
34-
35-
36-
37-
38QVector4D::QVector4D(const QVector3D& vector, float wpos)-
39{-
40 xp = vector.xp;-
41 yp = vector.yp;-
42 zp = vector.zp;-
43 wp = wpos;-
44}
never executed: end of block
0
45float QVector4D::length() const-
46{-
47-
48 double len = double(xp) * double(xp) +-
49 double(yp) * double(yp) +-
50 double(zp) * double(zp) +-
51 double(wp) * double(wp);-
52 return
never executed: return float(std::sqrt(len));
float(std::sqrt(len));
never executed: return float(std::sqrt(len));
0
53}-
54-
55-
56-
57-
58-
59-
60-
61float QVector4D::lengthSquared() const-
62{-
63 return
never executed: return xp * xp + yp * yp + zp * zp + wp * wp;
xp * xp + yp * yp + zp * zp + wp * wp;
never executed: return xp * xp + yp * yp + zp * zp + wp * wp;
0
64}-
65QVector4D QVector4D::normalized() const-
66{-
67-
68 double len = double(xp) * double(xp) +-
69 double(yp) * double(yp) +-
70 double(zp) * double(zp) +-
71 double(wp) * double(wp);-
72 if (qFuzzyIsNull(len - 1.0f)
qFuzzyIsNull(len - 1.0f)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
73 return
never executed: return *this;
*this;
never executed: return *this;
0
74 } else if (!qFuzzyIsNull(len)
!qFuzzyIsNull(len)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
75 double sqrtLen = std::sqrt(len);-
76 return
never executed: return QVector4D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen), float(double(wp) / sqrtLen));
QVector4D(float(double(xp) / sqrtLen),
never executed: return QVector4D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen), float(double(wp) / sqrtLen));
0
77 float(double(yp) / sqrtLen),
never executed: return QVector4D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen), float(double(wp) / sqrtLen));
0
78 float(double(zp) / sqrtLen),
never executed: return QVector4D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen), float(double(wp) / sqrtLen));
0
79 float(double(wp) / sqrtLen));
never executed: return QVector4D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen), float(double(wp) / sqrtLen));
0
80 } else {-
81 return
never executed: return QVector4D();
QVector4D();
never executed: return QVector4D();
0
82 }-
83}-
84-
85-
86-
87-
88-
89-
90-
91void QVector4D::normalize()-
92{-
93-
94 double len = double(xp) * double(xp) +-
95 double(yp) * double(yp) +-
96 double(zp) * double(zp) +-
97 double(wp) * double(wp);-
98 if (qFuzzyIsNull(len - 1.0f)
qFuzzyIsNull(len - 1.0f)Description
TRUEnever evaluated
FALSEnever evaluated
|| qFuzzyIsNull(len)
qFuzzyIsNull(len)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
99 return;
never executed: return;
0
100-
101 len = std::sqrt(len);-
102-
103 xp = float(double(xp) / len);-
104 yp = float(double(yp) / len);-
105 zp = float(double(zp) / len);-
106 wp = float(double(wp) / len);-
107}
never executed: end of block
0
108float QVector4D::dotProduct(const QVector4D& v1, const QVector4D& v2)-
109{-
110 return
never executed: return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp;
v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp;
never executed: return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp;
0
111}-
112QVector2D QVector4D::toVector2D() const-
113{-
114 return
never executed: return QVector2D(xp, yp);
QVector2D(xp, yp);
never executed: return QVector2D(xp, yp);
0
115}-
116QVector2D QVector4D::toVector2DAffine() const-
117{-
118 if (qIsNull(wp)
qIsNull(wp)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
119 return
never executed: return QVector2D();
QVector2D();
never executed: return QVector2D();
0
120 return
never executed: return QVector2D(xp / wp, yp / wp);
QVector2D(xp / wp, yp / wp);
never executed: return QVector2D(xp / wp, yp / wp);
0
121}-
122QVector3D QVector4D::toVector3D() const-
123{-
124 return
never executed: return QVector3D(xp, yp, zp);
QVector3D(xp, yp, zp);
never executed: return QVector3D(xp, yp, zp);
0
125}-
126-
127-
128-
129-
130-
131-
132-
133QVector3D QVector4D::toVector3DAffine() const-
134{-
135 if (qIsNull(wp)
qIsNull(wp)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
136 return
never executed: return QVector3D();
QVector3D();
never executed: return QVector3D();
0
137 return
never executed: return QVector3D(xp / wp, yp / wp, zp / wp);
QVector3D(xp / wp, yp / wp, zp / wp);
never executed: return QVector3D(xp / wp, yp / wp, zp / wp);
0
138}-
139QVector4D::operator QVariant() const-
140{-
141 return
never executed: return QVariant(QVariant::Vector4D, this);
QVariant(QVariant::Vector4D, this);
never executed: return QVariant(QVariant::Vector4D, this);
0
142}-
143-
144-
145-
146QDebug operator<<(QDebug dbg, const QVector4D &vector)-
147{-
148 QDebugStateSaver saver(dbg);-
149 dbg.nospace() << "QVector4D("-
150 << vector.x() << ", " << vector.y() << ", "-
151 << vector.z() << ", " << vector.w() << ')';-
152 return
never executed: return dbg;
dbg;
never executed: return dbg;
0
153}-
154QDataStream &operator<<(QDataStream &stream, const QVector4D &vector)-
155{-
156 stream << vector.x() << vector.y()-
157 << vector.z() << vector.w();-
158 return
never executed: return stream;
stream;
never executed: return stream;
0
159}-
160QDataStream &operator>>(QDataStream &stream, QVector4D &vector)-
161{-
162 float x, y, z, w;-
163 stream >> x;-
164 stream >> y;-
165 stream >> z;-
166 stream >> w;-
167 vector.setX(x);-
168 vector.setY(y);-
169 vector.setZ(z);-
170 vector.setW(w);-
171 return
never executed: return stream;
stream;
never executed: return stream;
0
172}-
173-
174-
175-
176-
177-
178-
Switch to Source codePreprocessed file

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