 Home · All Classes · Modules

QVector4D Class Reference[QtGui module]

The QVector4D class represents a vector or vertex in 4D space. More...

Special Methods

• QVector4D __add__ (self, QVector4D v2)
• QVector4D __div__ (self, float divisor)
• bool __eq__ (self, QVector4D v2)
• QVector4D __iadd__ (self, QVector4D vector)
• QVector4D __idiv__ (self, float divisor)
• QVector4D __imul__ (self, float factor)
• QVector4D __imul__ (self, QVector4D vector)
• QVector4D __isub__ (self, QVector4D vector)
• QVector4D __mul__ (self, QMatrix4x4 matrix)
• QVector4D __mul__ (self, QVector4D vector)
• QVector4D __mul__ (self, float factor)
• QVector4D __mul__ (self, QVector4D v2)
• bool __ne__ (self, QVector4D v2)
• QVector4D __neg__ (self)
• str __repr__ (self)
• QVector4D __sub__ (self, QVector4D v2)

Detailed Description

This class can be pickled.

The QVector4D class represents a vector or vertex in 4D space.

The QVector4D class can also be used to represent vertices in 4D space. We therefore do not need to provide a separate vertex class.

Note: By design values in the QVector4D instance are stored as float. This means that on platforms where the qreal arguments to QVector4D functions are represented by double values, it is possible to lose precision.

Method Documentation

QVector4D.__init__ (self)

Constructs a null vector, i.e. with coordinates (0, 0, 0, 0).

QVector4D.__init__ (self, float xpos, float ypos, float zpos, float wpos)

Constructs a vector with coordinates (xpos, ypos, zpos, wpos).

QVector4D.__init__ (self, QPointpoint)

Constructs a vector with x and y coordinates from a 2D point, and z and w coordinates of 0.

QVector4D.__init__ (self, QPointFpoint)

Constructs a vector with x and y coordinates from a 2D point, and z and w coordinates of 0.

QVector4D.__init__ (self, QVector2Dvector)

Constructs a 4D vector from the specified 2D vector. The z and w coordinates are set to zero.

QVector4D.__init__ (self, QVector2Dvector, float zpos, float wpos)

Constructs a 4D vector from the specified 2D vector. The z and w coordinates are set to zpos and wpos respectively.

QVector4D.__init__ (self, QVector3Dvector)

Constructs a 4D vector from the specified 3D vector. The w coordinate is set to zero.

QVector4D.__init__ (self, QVector3Dvector, float wpos)

Constructs a 4D vector from the specified 3D vector. The w coordinate is set to wpos.

float QVector4D.dotProduct (QVector4Dv1, QVector4Dv2)

Returns the dot product of v1 and v2.

bool QVector4D.isNull (self)

Returns true if the x, y, z, and w coordinates are set to 0.0, otherwise returns false.

float QVector4D.length (self)

Returns the length of the vector from the origin.

float QVector4D.lengthSquared (self)

Returns the squared length of the vector from the origin. This is equivalent to the dot product of the vector with itself.

QVector4D.normalize (self)

Normalizes the currect vector in place. Nothing happens if this vector is a null vector or the length of the vector is very close to 1.

QVector4D QVector4D.normalized (self)

Returns the normalized unit vector form of this vector.

If this vector is null, then a null vector is returned. If the length of the vector is very close to 1, then the vector will be returned as-is. Otherwise the normalized form of the vector of length 1 will be returned.

QVector4D.setW (self, float aW)

Sets the w coordinate of this point to the given w coordinate.

QVector4D.setX (self, float aX)

Sets the x coordinate of this point to the given x coordinate.

QVector4D.setY (self, float aY)

Sets the y coordinate of this point to the given y coordinate.

QVector4D.setZ (self, float aZ)

Sets the z coordinate of this point to the given z coordinate.

QPoint QVector4D.toPoint (self)

Returns the QPoint form of this 4D vector. The z and w coordinates are dropped.

QPointF QVector4D.toPointF (self)

Returns the QPointF form of this 4D vector. The z and w coordinates are dropped.

QVector2D QVector4D.toVector2D (self)

Returns the 2D vector form of this 4D vector, dropping the z and w coordinates.

QVector2D QVector4D.toVector2DAffine (self)

Returns the 2D vector form of this 4D vector, dividing the x and y coordinates by the w coordinate and dropping the z coordinate. Returns a null vector if w is zero.

QVector3D QVector4D.toVector3D (self)

Returns the 3D vector form of this 4D vector, dropping the w coordinate.

QVector3D QVector4D.toVector3DAffine (self)

Returns the 3D vector form of this 4D vector, dividing the x, y, and z coordinates by the w coordinate. Returns a null vector if w is zero.

float QVector4D.w (self)

Returns the w coordinate of this point.

float QVector4D.x (self)

Returns the x coordinate of this point.

float QVector4D.y (self)

Returns the y coordinate of this point.

float QVector4D.z (self)

Returns the z coordinate of this point.

QVector4D QVector4D.__sub__ (self, QVector4Dv2)

 PyQt 4.9.4 for Windows Copyright © Riverbank Computing Ltd and Nokia 2012 Qt 4.8.2