Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QVector4D Class

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

Header:#include <QVector4D>
Since: Qt 4.6

Public 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)
boolisNull() const
qreallength() const
qreallengthSquared() const
voidnormalize()
QVector4Dnormalized() const
voidsetW(qreal w)
voidsetX(qreal x)
voidsetY(qreal y)
voidsetZ(qreal z)
QPointtoPoint() const
QPointFtoPointF() const
QVector2DtoVector2D() const
QVector2DtoVector2DAffine() const
QVector3DtoVector3D() const
QVector3DtoVector3DAffine() const
qrealw() const
qrealx() const
qrealy() const
qrealz() const
operator QVariant() const
QVector4D &operator*=(qreal factor)
QVector4D &operator*=(const QVector4D & vector)
QVector4D &operator+=(const QVector4D & vector)
QVector4D &operator-=(const QVector4D & vector)
QVector4D &operator/=(qreal divisor)

Static Public Members

qrealdotProduct(const QVector4D & v1, const QVector4D & v2)

Related Non-Members

boolqFuzzyCompare(const QVector4D & v1, const QVector4D & v2)
booloperator!=(const QVector4D & v1, const QVector4D & v2)
const QVector4Doperator*(qreal factor, const QVector4D & vector)
const QVector4Doperator*(const QVector4D & vector, qreal factor)
const QVector4Doperator*(const QVector4D & v1, const QVector4D & v2)
const QVector4Doperator+(const QVector4D & v1, const QVector4D & v2)
const QVector4Doperator-(const QVector4D & v1, const QVector4D & v2)
const QVector4Doperator-(const QVector4D & vector)
const QVector4Doperator/(const QVector4D & vector, qreal divisor)
QDataStream &operator<<(QDataStream & stream, const QVector4D & vector)
booloperator==(const QVector4D & v1, const QVector4D & v2)
QDataStream &operator>>(QDataStream & stream, QVector4D & vector)

Detailed Description

TheQVector4D class represents a vector or vertex in 4D space.

TheQVector4D 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 theQVector4D instance are stored asfloat. This means that on platforms where theqreal arguments toQVector4D functions are represented bydouble values, it is possible to lose precision.

See alsoQQuaternion,QVector2D, andQVector3D.

Member Function Documentation

QVector4D::QVector4D()

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

QVector4D::QVector4D(qreal xpos,qreal ypos,qreal zpos,qreal wpos)

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

QVector4D::QVector4D(constQPoint & point)

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

QVector4D::QVector4D(constQPointF & point)

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

QVector4D::QVector4D(constQVector2D & vector)

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

See alsotoVector2D().

QVector4D::QVector4D(constQVector2D & vector,qreal zpos,qreal wpos)

Constructs a 4D vector from the specified 2Dvector. The z and w coordinates are set tozpos andwpos respectively.

See alsotoVector2D().

QVector4D::QVector4D(constQVector3D & vector)

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

See alsotoVector3D().

QVector4D::QVector4D(constQVector3D & vector,qreal wpos)

Constructs a 4D vector from the specified 3Dvector. The w coordinate is set towpos.

See alsotoVector3D().

[static]qreal QVector4D::dotProduct(constQVector4D & v1, constQVector4D & v2)

Returns the dot product ofv1 andv2.

bool QVector4D::isNull() const

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

qreal QVector4D::length() const

Returns the length of the vector from the origin.

See alsolengthSquared() andnormalized().

qreal QVector4D::lengthSquared() const

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

See alsolength() anddotProduct().

void QVector4D::normalize()

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 alsolength() andnormalized().

QVector4D QVector4D::normalized() const

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 alsolength() andnormalize().

void QVector4D::setW(qreal w)

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

See alsow(),setX(),setY(), andsetZ().

void QVector4D::setX(qreal x)

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

See alsox(),setY(),setZ(), andsetW().

void QVector4D::setY(qreal y)

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

See alsoy(),setX(),setZ(), andsetW().

void QVector4D::setZ(qreal z)

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

See alsoz(),setX(),setY(), andsetW().

QPoint QVector4D::toPoint() const

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

See alsotoPointF() andtoVector2D().

QPointF QVector4D::toPointF() const

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

See alsotoPoint() andtoVector2D().

QVector2D QVector4D::toVector2D() const

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

See alsotoVector2DAffine(),toVector3D(), andtoPoint().

QVector2D QVector4D::toVector2DAffine() const

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.

See alsotoVector2D(),toVector3DAffine(), andtoPoint().

QVector3D QVector4D::toVector3D() const

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

See alsotoVector3DAffine(),toVector2D(), andtoPoint().

QVector3D QVector4D::toVector3DAffine() const

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.

See alsotoVector3D(),toVector2DAffine(), andtoPoint().

qreal QVector4D::w() const

Returns the w coordinate of this point.

See alsosetW(),x(),y(), andz().

qreal QVector4D::x() const

Returns the x coordinate of this point.

See alsosetX(),y(),z(), andw().

qreal QVector4D::y() const

Returns the y coordinate of this point.

See alsosetY(),x(),z(), andw().

qreal QVector4D::z() const

Returns the z coordinate of this point.

See alsosetZ(),x(),y(), andw().

QVector4D::operator QVariant() const

Returns the 4D vector as aQVariant.

QVector4D & QVector4D::operator*=(qreal factor)

Multiplies this vector's coordinates by the givenfactor, and returns a reference to this vector.

See alsooperator/=().

QVector4D & QVector4D::operator*=(constQVector4D & vector)

Multiplies the components of this vector by the corresponding components invector.

QVector4D & QVector4D::operator+=(constQVector4D & vector)

Adds the givenvector to this vector and returns a reference to this vector.

See alsooperator-=().

QVector4D & QVector4D::operator-=(constQVector4D & vector)

Subtracts the givenvector from this vector and returns a reference to this vector.

See alsooperator+=().

QVector4D & QVector4D::operator/=(qreal divisor)

Divides this vector's coordinates by the givendivisor, and returns a reference to this vector.

See alsooperator*=().

Related Non-Members

boolqFuzzyCompare(constQVector4D & v1, constQVector4D & v2)

Returns true ifv1 andv2 are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.

booloperator!=(constQVector4D & v1, constQVector4D & v2)

Returns true ifv1 is not equal tov2; otherwise returns false. This operator uses an exact floating-point comparison.

constQVector4Doperator*(qreal factor, constQVector4D & vector)

Returns a copy of the givenvector, multiplied by the givenfactor.

See alsoQVector4D::operator*=().

constQVector4Doperator*(constQVector4D & vector,qreal factor)

Returns a copy of the givenvector, multiplied by the givenfactor.

See alsoQVector4D::operator*=().

constQVector4Doperator*(constQVector4D & v1, constQVector4D & v2)

Returns the vector consisting of the multiplication of the components fromv1 andv2.

See alsoQVector4D::operator*=().

constQVector4Doperator+(constQVector4D & v1, constQVector4D & v2)

Returns aQVector4D object that is the sum of the given vectors,v1 andv2; each component is added separately.

See alsoQVector4D::operator+=().

constQVector4Doperator-(constQVector4D & v1, constQVector4D & v2)

Returns aQVector4D object that is formed by subtractingv2 fromv1; each component is subtracted separately.

See alsoQVector4D::operator-=().

constQVector4Doperator-(constQVector4D & vector)

This is an overloaded function.

Returns aQVector4D object that is formed by changing the sign of all three components of the givenvector.

Equivalent toQVector4D(0,0,0,0) - vector.

constQVector4Doperator/(constQVector4D & vector,qreal divisor)

Returns theQVector4D object formed by dividing all four components of the givenvector by the givendivisor.

See alsoQVector4D::operator/=().

QDataStream &operator<<(QDataStream & stream, constQVector4D & vector)

Writes the givenvector to the givenstream and returns a reference to the stream.

See alsoSerializing Qt Data Types.

booloperator==(constQVector4D & v1, constQVector4D & v2)

Returns true ifv1 is equal tov2; otherwise returns false. This operator uses an exact floating-point comparison.

QDataStream &operator>>(QDataStream & stream,QVector4D & vector)

Reads a 4D vector from the givenstream into the givenvector and returns a reference to the stream.

See alsoSerializing Qt Data Types.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp