QVector4D Class Reference

#include <qvector4d.h>

Class Description

Definition at line 60 of file qvector4d.h.

Public Member Functions

 QVector4D ()
 
 QVector4D (qreal xpos, qreal ypos, qreal zpos, qreal wpos)
 
 QVector4D (const QPoint &point)
 
 QVector4D (const QPointF &point)
 
 QVector4D (const QVector2D &vector)
 
 QVector4D (const QVector2D &vector, qreal zpos, qreal wpos)
 
 QVector4D (const QVector3D &vector)
 
 QVector4D (const QVector3D &vector, qreal wpos)
 
bool isNull () const
 
qreal x () const
 
qreal y () const
 
qreal z () const
 
qreal w () const
 
void setX (qreal x)
 
void setY (qreal y)
 
void setZ (qreal z)
 
void setW (qreal w)
 
qreal length () const
 
qreal lengthSquared () const
 
QVector4D normalized () const
 
void normalize ()
 
QVector4Doperator+= (const QVector4D &vector)
 
QVector4Doperator-= (const QVector4D &vector)
 
QVector4Doperator*= (qreal factor)
 
QVector4Doperator*= (const QVector4D &vector)
 
QVector4Doperator/= (qreal divisor)
 
QVector2D toVector2D () const
 
QVector2D toVector2DAffine () const
 
QVector3D toVector3D () const
 
QVector3D toVector3DAffine () const
 
QPoint toPoint () const
 
QPointF toPointF () const
 
 operator QVariant () const
 

Static Public Member Functions

static qreal dotProduct (const QVector4D &v1, const QVector4D &v2)
 

Friends

class QVector2D
 
class QVector3D
 
bool operator== (const QVector4D &v1, const QVector4D &v2)
 
bool operator!= (const QVector4D &v1, const QVector4D &v2)
 
const QVector4D operator+ (const QVector4D &v1, const QVector4D &v2)
 
const QVector4D operator- (const QVector4D &v1, const QVector4D &v2)
 
const QVector4D operator* (qreal factor, const QVector4D &vector)
 
const QVector4D operator* (const QVector4D &vector, qreal factor)
 
const QVector4D operator* (const QVector4D &v1, const QVector4D &v2)
 
const QVector4D operator- (const QVector4D &vector)
 
const QVector4D operator/ (const QVector4D &vector, qreal divisor)
 
bool qFuzzyCompare (const QVector4D &v1, const QVector4D &v2)
 
QVector4D operator* (const QVector4D &vector, const QMatrix4x4 &matrix)
 
QVector4D operator* (const QMatrix4x4 &matrix, const QVector4D &vector)
 

Constructor & Destructor Documentation

QVector4D ( )
inline

Definition at line 143 of file qvector4d.h.

143 : xp(0.0f), yp(0.0f), zp(0.0f), wp(0.0f) {}
GLclampf f
Definition: GLee.h:9303
QVector4D ( qreal  xpos,
qreal  ypos,
qreal  zpos,
qreal  wpos 
)
inline

Definition at line 145 of file qvector4d.h.

145 : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
QVector4D ( const QPoint point)
inlineexplicit

Definition at line 149 of file qvector4d.h.

149 : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
int y() const
Definition: qpoint.h:131
int x() const
Definition: qpoint.h:128
GLclampf f
Definition: GLee.h:9303
QVector4D ( const QPointF point)
inlineexplicit

Definition at line 151 of file qvector4d.h.

151 : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
qreal y() const
Definition: qpoint.h:287
qreal x() const
Definition: qpoint.h:282
GLclampf f
Definition: GLee.h:9303
QVector4D ( const QVector2D vector)
QVector4D ( const QVector2D vector,
qreal  zpos,
qreal  wpos 
)
QVector4D ( const QVector3D vector)
QVector4D ( const QVector3D vector,
qreal  wpos 
)

Member Function Documentation

bool isNull ( ) const
inline

Definition at line 153 of file qvector4d.h.

154 {
155  return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
156 }
qreal x ( ) const
inline

Definition at line 158 of file qvector4d.h.

158 { return qreal(xp); }
qreal y ( ) const
inline

Definition at line 159 of file qvector4d.h.

159 { return qreal(yp); }
qreal z ( ) const
inline

Definition at line 160 of file qvector4d.h.

160 { return qreal(zp); }
qreal w ( ) const
inline

Definition at line 161 of file qvector4d.h.

161 { return qreal(wp); }
void setX ( qreal  x)
inline

Definition at line 163 of file qvector4d.h.

163 { xp = aX; }
void setY ( qreal  y)
inline

Definition at line 164 of file qvector4d.h.

164 { yp = aY; }
void setZ ( qreal  z)
inline

Definition at line 165 of file qvector4d.h.

165 { zp = aZ; }
void setW ( qreal  w)
inline

Definition at line 166 of file qvector4d.h.

166 { wp = aW; }
qreal length ( ) const
qreal lengthSquared ( ) const
QVector4D normalized ( ) const
void normalize ( )
QVector4D & operator+= ( const QVector4D vector)
inline

Definition at line 168 of file qvector4d.h.

169 {
170  xp += vector.xp;
171  yp += vector.yp;
172  zp += vector.zp;
173  wp += vector.wp;
174  return *this;
175 }
QVector4D & operator-= ( const QVector4D vector)
inline

Definition at line 177 of file qvector4d.h.

178 {
179  xp -= vector.xp;
180  yp -= vector.yp;
181  zp -= vector.zp;
182  wp -= vector.wp;
183  return *this;
184 }
QVector4D & operator*= ( qreal  factor)
inline

Definition at line 186 of file qvector4d.h.

187 {
188  xp *= factor;
189  yp *= factor;
190  zp *= factor;
191  wp *= factor;
192  return *this;
193 }
QVector4D & operator*= ( const QVector4D vector)
inline

Definition at line 195 of file qvector4d.h.

196 {
197  xp *= vector.xp;
198  yp *= vector.yp;
199  zp *= vector.zp;
200  wp *= vector.wp;
201  return *this;
202 }
QVector4D & operator/= ( qreal  divisor)
inline

Definition at line 204 of file qvector4d.h.

205 {
206  xp /= divisor;
207  yp /= divisor;
208  zp /= divisor;
209  wp /= divisor;
210  return *this;
211 }
GLXDrawable int64_t int64_t divisor
Definition: GLee.h:10690
static qreal dotProduct ( const QVector4D v1,
const QVector4D v2 
)
static
QVector2D toVector2D ( ) const
QVector2D toVector2DAffine ( ) const
QVector3D toVector3D ( ) const
QVector3D toVector3DAffine ( ) const
QPoint toPoint ( ) const
inline

Definition at line 266 of file qvector4d.h.

267 {
268  return QPoint(qRound(xp), qRound(yp));
269 }
Definition: qpoint.h:53
QPointF toPointF ( ) const
inline

Definition at line 271 of file qvector4d.h.

272 {
273  return QPointF(qreal(xp), qreal(yp));
274 }
operator QVariant ( ) const

Friends And Related Function Documentation

friend class QVector2D
friend

Definition at line 133 of file qvector4d.h.

friend class QVector3D
friend

Definition at line 134 of file qvector4d.h.

bool operator== ( const QVector4D v1,
const QVector4D v2 
)
friend

Definition at line 213 of file qvector4d.h.

214 {
215  return v1.xp == v2.xp && v1.yp == v2.yp && v1.zp == v2.zp && v1.wp == v2.wp;
216 }
bool operator!= ( const QVector4D v1,
const QVector4D v2 
)
friend

Definition at line 218 of file qvector4d.h.

219 {
220  return v1.xp != v2.xp || v1.yp != v2.yp || v1.zp != v2.zp || v1.wp != v2.wp;
221 }
const QVector4D operator+ ( const QVector4D v1,
const QVector4D v2 
)
friend

Definition at line 223 of file qvector4d.h.

224 {
225  return QVector4D(v1.xp + v2.xp, v1.yp + v2.yp, v1.zp + v2.zp, v1.wp + v2.wp, 1);
226 }
const QVector4D operator- ( const QVector4D v1,
const QVector4D v2 
)
friend

Definition at line 228 of file qvector4d.h.

229 {
230  return QVector4D(v1.xp - v2.xp, v1.yp - v2.yp, v1.zp - v2.zp, v1.wp - v2.wp, 1);
231 }
const QVector4D operator* ( qreal  factor,
const QVector4D vector 
)
friend

Definition at line 233 of file qvector4d.h.

234 {
235  return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
236 }
const QVector4D operator* ( const QVector4D vector,
qreal  factor 
)
friend

Definition at line 238 of file qvector4d.h.

239 {
240  return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
241 }
const QVector4D operator* ( const QVector4D v1,
const QVector4D v2 
)
friend

Definition at line 243 of file qvector4d.h.

244 {
245  return QVector4D(v1.xp * v2.xp, v1.yp * v2.yp, v1.zp * v2.zp, v1.wp * v2.wp, 1);
246 }
const QVector4D operator- ( const QVector4D vector)
friend

Definition at line 248 of file qvector4d.h.

249 {
250  return QVector4D(-vector.xp, -vector.yp, -vector.zp, -vector.wp, 1);
251 }
const QVector4D operator/ ( const QVector4D vector,
qreal  divisor 
)
friend

Definition at line 253 of file qvector4d.h.

254 {
255  return QVector4D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, vector.wp / divisor, 1);
256 }
GLXDrawable int64_t int64_t divisor
Definition: GLee.h:10690
bool qFuzzyCompare ( const QVector4D v1,
const QVector4D v2 
)
friend

Definition at line 258 of file qvector4d.h.

259 {
260  return qFuzzyCompare(v1.xp, v2.xp) &&
261  qFuzzyCompare(v1.yp, v2.yp) &&
262  qFuzzyCompare(v1.zp, v2.zp) &&
263  qFuzzyCompare(v1.wp, v2.wp);
264 }
friend bool qFuzzyCompare(const QVector4D &v1, const QVector4D &v2)
Definition: qvector4d.h:258
QVector4D operator* ( const QVector4D vector,
const QMatrix4x4 matrix 
)
friend

Definition at line 677 of file qmatrix4x4.h.

678 {
679  qreal x, y, z, w;
680  x = vector.x() * matrix.m[0][0] +
681  vector.y() * matrix.m[0][1] +
682  vector.z() * matrix.m[0][2] +
683  vector.w() * matrix.m[0][3];
684  y = vector.x() * matrix.m[1][0] +
685  vector.y() * matrix.m[1][1] +
686  vector.z() * matrix.m[1][2] +
687  vector.w() * matrix.m[1][3];
688  z = vector.x() * matrix.m[2][0] +
689  vector.y() * matrix.m[2][1] +
690  vector.z() * matrix.m[2][2] +
691  vector.w() * matrix.m[2][3];
692  w = vector.x() * matrix.m[3][0] +
693  vector.y() * matrix.m[3][1] +
694  vector.z() * matrix.m[3][2] +
695  vector.w() * matrix.m[3][3];
696  return QVector4D(x, y, z, w);
697 }
qreal x() const
Definition: qvector4d.h:158
qreal w() const
Definition: qvector4d.h:161
qreal y() const
Definition: qvector4d.h:159
qreal z() const
Definition: qvector4d.h:160
QVector4D operator* ( const QMatrix4x4 matrix,
const QVector4D vector 
)
friend

Definition at line 699 of file qmatrix4x4.h.

700 {
701  qreal x, y, z, w;
702  x = vector.x() * matrix.m[0][0] +
703  vector.y() * matrix.m[1][0] +
704  vector.z() * matrix.m[2][0] +
705  vector.w() * matrix.m[3][0];
706  y = vector.x() * matrix.m[0][1] +
707  vector.y() * matrix.m[1][1] +
708  vector.z() * matrix.m[2][1] +
709  vector.w() * matrix.m[3][1];
710  z = vector.x() * matrix.m[0][2] +
711  vector.y() * matrix.m[1][2] +
712  vector.z() * matrix.m[2][2] +
713  vector.w() * matrix.m[3][2];
714  w = vector.x() * matrix.m[0][3] +
715  vector.y() * matrix.m[1][3] +
716  vector.z() * matrix.m[2][3] +
717  vector.w() * matrix.m[3][3];
718  return QVector4D(x, y, z, w);
719 }
qreal x() const
Definition: qvector4d.h:158
qreal w() const
Definition: qvector4d.h:161
qreal y() const
Definition: qvector4d.h:159
qreal z() const
Definition: qvector4d.h:160

The documentation for this class was generated from the following file: