| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/math3d/qvector4d.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | QVector4D::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 | - | |||||||||||||
| 17 | QVector4D::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 | ||||||||||||
| 24 | QVector4D::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 | - | |||||||||||||
| 38 | QVector4D::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 | ||||||||||||
| 45 | float 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: float(std::sqrt(len));return float(std::sqrt(len));never executed: return float(std::sqrt(len)); | 0 | ||||||||||||
| 53 | } | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | - | |||||||||||||
| 56 | - | |||||||||||||
| 57 | - | |||||||||||||
| 58 | - | |||||||||||||
| 59 | - | |||||||||||||
| 60 | - | |||||||||||||
| 61 | float QVector4D::lengthSquared() const | - | ||||||||||||
| 62 | { | - | ||||||||||||
| 63 | return never executed: xp * xp + yp * yp + zp * zp + wp * wp;return xp * xp + yp * yp + zp * zp + wp * wp;never executed: return xp * xp + yp * yp + zp * zp + wp * wp; | 0 | ||||||||||||
| 64 | } | - | ||||||||||||
| 65 | QVector4D 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)
| 0 | ||||||||||||
| 73 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||
| 74 | } else if (!qFuzzyIsNull(len)
| 0 | ||||||||||||
| 75 | double sqrtLen = std::sqrt(len); | - | ||||||||||||
| 76 | return never executed: QVector4D(float(double(xp) / sqrtLen),return QVector4D(float(double(xp) / sqrtLen), float(double(yp) / sqrtLen), float(double(zp) / sqrtLen), 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 | ||||||||||||
| 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: QVector4D();return QVector4D();never executed: return QVector4D(); | 0 | ||||||||||||
| 82 | } | - | ||||||||||||
| 83 | } | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | - | |||||||||||||
| 86 | - | |||||||||||||
| 87 | - | |||||||||||||
| 88 | - | |||||||||||||
| 89 | - | |||||||||||||
| 90 | - | |||||||||||||
| 91 | void 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)
| 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 | ||||||||||||
| 108 | float QVector4D::dotProduct(const QVector4D& v1, const QVector4D& v2) | - | ||||||||||||
| 109 | { | - | ||||||||||||
| 110 | return never executed: v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp;return 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 | } | - | ||||||||||||
| 112 | QVector2D QVector4D::toVector2D() const | - | ||||||||||||
| 113 | { | - | ||||||||||||
| 114 | return never executed: QVector2D(xp, yp);return QVector2D(xp, yp);never executed: return QVector2D(xp, yp); | 0 | ||||||||||||
| 115 | } | - | ||||||||||||
| 116 | QVector2D QVector4D::toVector2DAffine() const | - | ||||||||||||
| 117 | { | - | ||||||||||||
| 118 | if (qIsNull(wp)
| 0 | ||||||||||||
| 119 | return never executed: QVector2D();return QVector2D();never executed: return QVector2D(); | 0 | ||||||||||||
| 120 | return never executed: QVector2D(xp / wp, yp / wp);return QVector2D(xp / wp, yp / wp);never executed: return QVector2D(xp / wp, yp / wp); | 0 | ||||||||||||
| 121 | } | - | ||||||||||||
| 122 | QVector3D QVector4D::toVector3D() const | - | ||||||||||||
| 123 | { | - | ||||||||||||
| 124 | return never executed: QVector3D(xp, yp, zp);return QVector3D(xp, yp, zp);never executed: return QVector3D(xp, yp, zp); | 0 | ||||||||||||
| 125 | } | - | ||||||||||||
| 126 | - | |||||||||||||
| 127 | - | |||||||||||||
| 128 | - | |||||||||||||
| 129 | - | |||||||||||||
| 130 | - | |||||||||||||
| 131 | - | |||||||||||||
| 132 | - | |||||||||||||
| 133 | QVector3D QVector4D::toVector3DAffine() const | - | ||||||||||||
| 134 | { | - | ||||||||||||
| 135 | if (qIsNull(wp)
| 0 | ||||||||||||
| 136 | return never executed: QVector3D();return QVector3D();never executed: return QVector3D(); | 0 | ||||||||||||
| 137 | return never executed: QVector3D(xp / wp, yp / wp, zp / wp);return QVector3D(xp / wp, yp / wp, zp / wp);never executed: return QVector3D(xp / wp, yp / wp, zp / wp); | 0 | ||||||||||||
| 138 | } | - | ||||||||||||
| 139 | QVector4D::operator QVariant() const | - | ||||||||||||
| 140 | { | - | ||||||||||||
| 141 | return never executed: QVariant(QVariant::Vector4D, this);return QVariant(QVariant::Vector4D, this);never executed: return QVariant(QVariant::Vector4D, this); | 0 | ||||||||||||
| 142 | } | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | - | |||||||||||||
| 145 | - | |||||||||||||
| 146 | QDebug 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: dbg;return dbg;never executed: return dbg; | 0 | ||||||||||||
| 153 | } | - | ||||||||||||
| 154 | QDataStream &operator<<(QDataStream &stream, const QVector4D &vector) | - | ||||||||||||
| 155 | { | - | ||||||||||||
| 156 | stream << vector.x() << vector.y() | - | ||||||||||||
| 157 | << vector.z() << vector.w(); | - | ||||||||||||
| 158 | return never executed: stream;return stream;never executed: return stream; | 0 | ||||||||||||
| 159 | } | - | ||||||||||||
| 160 | QDataStream &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: stream;return stream;never executed: return stream; | 0 | ||||||||||||
| 172 | } | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | - | |||||||||||||
| 175 | - | |||||||||||||
| 176 | - | |||||||||||||
| 177 | - | |||||||||||||
| 178 | - | |||||||||||||
| Switch to Source code | Preprocessed file |