Home · All Classes · Modules

QVector3D Class Reference
[QtGui module]

The QVector3D class represents a vector or vertex in 3D space. More...

Methods

Static Methods

Special Methods


Detailed Description

This class can be pickled.

The QVector3D class represents a vector or vertex in 3D space.

Vectors are one of the main building blocks of 3D representation and drawing. They consist of three coordinates, traditionally called x, y, and z.

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

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


Method Documentation

QVector3D.__init__ (self)

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

QVector3D.__init__ (self, float xpos, float ypos, float zpos)

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

QVector3D.__init__ (self, QPoint point)

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

QVector3D.__init__ (self, QPointF point)

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

QVector3D.__init__ (self, QVector2D vector)

Constructs a 3D vector from the specified 2D vector. The z coordinate is set to zero.

See also toVector2D().

QVector3D.__init__ (self, QVector2D vector, float zpos)

Constructs a 3D vector from the specified 2D vector. The z coordinate is set to zpos.

See also toVector2D().

QVector3D.__init__ (self, QVector4D vector)

Constructs a 3D vector from the specified 4D vector. The w coordinate is dropped.

See also toVector4D().

QVector3D.__init__ (self, QVector3D)

QVector3D QVector3D.crossProduct (QVector3D v1, QVector3D v2)

Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2.

See also normal().

float QVector3D.distanceToLine (self, QVector3D point, QVector3D direction)

Returns the distance that this vertex is from a line defined by point and the unit vector direction.

If direction is a null vector, then it does not define a line. In that case, the distance from point to this vertex is returned.

See also distanceToPlane().

float QVector3D.distanceToPlane (self, QVector3D plane, QVector3D normal)

Returns the distance from this vertex to a plane defined by the vertex plane and a normal unit vector. The normal parameter is assumed to have been normalized to a unit vector.

The return value will be negative if the vertex is below the plane, or zero if it is on the plane.

See also normal() and distanceToLine().

float QVector3D.distanceToPlane (self, QVector3D plane1, QVector3D plane2, QVector3D plane3)

This is an overloaded function.

Returns the distance from this vertex a plane defined by the vertices plane1, plane2 and plane3.

The return value will be negative if the vertex is below the plane, or zero if it is on the plane.

The two vectors that define the plane are plane2 - plane1 and plane3 - plane1.

See also normal() and distanceToLine().

float QVector3D.dotProduct (QVector3D v1, QVector3D v2)

Returns the dot product of v1 and v2.

bool QVector3D.isNull (self)

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

float QVector3D.length (self)

Returns the length of the vector from the origin.

See also lengthSquared() and normalized().

float QVector3D.lengthSquared (self)

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

See also length() and dotProduct().

QVector3D QVector3D.normal (QVector3D v1, QVector3D v2)

Returns the normal vector of a plane defined by vectors v1 and v2, normalized to be a unit vector.

Use crossProduct() to compute the cross-product of v1 and v2 if you do not need the result to be normalized to a unit vector.

See also crossProduct() and distanceToPlane().

QVector3D QVector3D.normal (QVector3D v1, QVector3D v2, QVector3D v3)

This is an overloaded function.

Returns the normal vector of a plane defined by vectors v2 - v1 and v3 - v1, normalized to be a unit vector.

Use crossProduct() to compute the cross-product of v2 - v1 and v3 - v1 if you do not need the result to be normalized to a unit vector.

See also crossProduct() and distanceToPlane().

QVector3D.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.

See also length() and normalized().

QVector3D QVector3D.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.

See also length() and normalize().

QVector3D.setX (self, float aX)

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

See also x(), setY(), and setZ().

QVector3D.setY (self, float aY)

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

See also y(), setX(), and setZ().

QVector3D.setZ (self, float aZ)

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

See also z(), setX(), and setY().

QPoint QVector3D.toPoint (self)

Returns the QPoint form of this 3D vector. The z coordinate is dropped.

See also toPointF() and toVector2D().

QPointF QVector3D.toPointF (self)

Returns the QPointF form of this 3D vector. The z coordinate is dropped.

See also toPoint() and toVector2D().

QVector2D QVector3D.toVector2D (self)

Returns the 2D vector form of this 3D vector, dropping the z coordinate.

See also toVector4D() and toPoint().

QVector4D QVector3D.toVector4D (self)

Returns the 4D form of this 3D vector, with the w coordinate set to zero.

See also toVector2D() and toPoint().

float QVector3D.x (self)

Returns the x coordinate of this point.

See also setX(), y(), and z().

float QVector3D.y (self)

Returns the y coordinate of this point.

See also setY(), x(), and z().

float QVector3D.z (self)

Returns the z coordinate of this point.

See also setZ(), x(), and y().

QVector3D QVector3D.__add__ (self, QVector3D v2)

QVector3D QVector3D.__div__ (self, float divisor)

bool QVector3D.__eq__ (self, QVector3D v2)

QVector3D QVector3D.__iadd__ (self, QVector3D vector)

QVector3D QVector3D.__idiv__ (self, float divisor)

QVector3D QVector3D.__imul__ (self, float factor)

QVector3D QVector3D.__imul__ (self, QVector3D vector)

QVector3D QVector3D.__isub__ (self, QVector3D vector)

QVector3D QVector3D.__mul__ (self, QMatrix4x4 matrix)

QVector3D QVector3D.__mul__ (self, QVector3D vector)

QVector3D QVector3D.__mul__ (self, float factor)

QVector3D QVector3D.__mul__ (self, QVector3D v2)

bool QVector3D.__ne__ (self, QVector3D v2)

QVector3D QVector3D.__neg__ (self)

str QVector3D.__repr__ (self)

QVector3D QVector3D.__sub__ (self, QVector3D v2)


PyQt 4.11.4 for X11Copyright © Riverbank Computing Ltd and The Qt Company 2015Qt 4.8.7