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

QQuaternion Class

TheQQuaternion class represents a quaternion consisting of a vector and scalar.More...

Header:#include <QQuaternion>
Since: Qt 4.6

Public Functions

QQuaternion()
QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos)
QQuaternion(qreal scalar, const QVector3D & vector)
QQuaternion(const QVector4D & vector)
QQuaternionconjugate() const
boolisIdentity() const
boolisNull() const
qreallength() const
qreallengthSquared() const
voidnormalize()
QQuaternionnormalized() const
QVector3DrotatedVector(const QVector3D & vector) const
qrealscalar() const
voidsetScalar(qreal scalar)
voidsetVector(const QVector3D & vector)
voidsetVector(qreal x, qreal y, qreal z)
voidsetX(qreal x)
voidsetY(qreal y)
voidsetZ(qreal z)
QVector4DtoVector4D() const
QVector3Dvector() const
qrealx() const
qrealy() const
qrealz() const
operator QVariant() const
QQuaternion &operator*=(qreal factor)
QQuaternion &operator*=(const QQuaternion & quaternion)
QQuaternion &operator+=(const QQuaternion & quaternion)
QQuaternion &operator-=(const QQuaternion & quaternion)
QQuaternion &operator/=(qreal divisor)

Static Public Members

QQuaternionfromAxisAndAngle(const QVector3D & axis, qreal angle)
QQuaternionfromAxisAndAngle(qreal x, qreal y, qreal z, qreal angle)
QQuaternionnlerp(const QQuaternion & q1, const QQuaternion & q2, qreal t)
QQuaternionslerp(const QQuaternion & q1, const QQuaternion & q2, qreal t)

Related Non-Members

boolqFuzzyCompare(const QQuaternion & q1, const QQuaternion & q2)
booloperator!=(const QQuaternion & q1, const QQuaternion & q2)
const QQuaternionoperator*(const QQuaternion & q1, const QQuaternion & q2)
const QQuaternionoperator*(qreal factor, const QQuaternion & quaternion)
const QQuaternionoperator*(const QQuaternion & quaternion, qreal factor)
const QQuaternionoperator+(const QQuaternion & q1, const QQuaternion & q2)
const QQuaternionoperator-(const QQuaternion & q1, const QQuaternion & q2)
const QQuaternionoperator-(const QQuaternion & quaternion)
const QQuaternionoperator/(const QQuaternion & quaternion, qreal divisor)
QDataStream &operator<<(QDataStream & stream, const QQuaternion & quaternion)
booloperator==(const QQuaternion & q1, const QQuaternion & q2)
QDataStream &operator>>(QDataStream & stream, QQuaternion & quaternion)
QDataStream &operator>>(QDataStream & stream, QEasingCurve & easing)

Detailed Description

TheQQuaternion class represents a quaternion consisting of a vector and scalar.

Quaternions are used to represent rotations in 3D space, and consist of a 3D rotation axis specified by the x, y, and z coordinates, and a scalar representing the rotation angle.

Member Function Documentation

QQuaternion::QQuaternion()

Constructs an identity quaternion, i.e. with coordinates (1, 0, 0, 0).

QQuaternion::QQuaternion(qreal scalar,qreal xpos,qreal ypos,qreal zpos)

Constructs a quaternion with the vector (xpos,ypos,zpos) andscalar.

QQuaternion::QQuaternion(qreal scalar, constQVector3D & vector)

Constructs a quaternion vector from the specifiedvector andscalar.

See alsovector() andscalar().

QQuaternion::QQuaternion(constQVector4D & vector)

Constructs a quaternion from the components ofvector.

QQuaternion QQuaternion::conjugate() const

Returns the conjugate of this quaternion, which is (-x, -y, -z, scalar).

[static]QQuaternion QQuaternion::fromAxisAndAngle(constQVector3D & axis,qreal angle)

Creates a normalized quaternion that corresponds to rotating throughangle degrees about the specified 3Daxis.

[static]QQuaternion QQuaternion::fromAxisAndAngle(qreal x,qreal y,qreal z,qreal angle)

Creates a normalized quaternion that corresponds to rotating throughangle degrees about the 3D axis (x,y,z).

bool QQuaternion::isIdentity() const

Returns true if the x, y, and z components of this quaternion are set to 0.0, and the scalar component is set to 1.0; otherwise returns false.

bool QQuaternion::isNull() const

Returns true if the x, y, z, and scalar components of this quaternion are set to 0.0; otherwise returns false.

qreal QQuaternion::length() const

Returns the length of the quaternion. This is also called the "norm".

See alsolengthSquared() andnormalized().

qreal QQuaternion::lengthSquared() const

Returns the squared length of the quaternion.

See alsolength().

[static]QQuaternion QQuaternion::nlerp(constQQuaternion & q1, constQQuaternion & q2,qreal t)

Interpolates along the shortest linear path between the rotational positionsq1 andq2. The valuet should be between 0 and 1, indicating the distance to travel betweenq1 andq2. The result will benormalized().

Ift is less than or equal to 0, thenq1 will be returned. Ift is greater than or equal to 1, thenq2 will be returned.

The nlerp() function is typically faster thanslerp() and will give approximate results to spherical interpolation that are good enough for some applications.

See alsoslerp().

void QQuaternion::normalize()

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

See alsolength() andnormalized().

QQuaternion QQuaternion::normalized() const

Returns the normalized unit form of this quaternion.

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

See alsolength() andnormalize().

QVector3D QQuaternion::rotatedVector(constQVector3D & vector) const

Rotatesvector with this quaternion to produce a new vector in 3D space. The following code:

QVector3D result= q.rotatedVector(vector);

is equivalent to the following:

QVector3D result= (q*QQuaternion(0, vector)* q.conjugate()).vector();

qreal QQuaternion::scalar() const

Returns the scalar component of this quaternion.

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

void QQuaternion::setScalar(qreal scalar)

Sets the scalar component of this quaternion toscalar.

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

void QQuaternion::setVector(constQVector3D & vector)

Sets the vector component of this quaternion tovector.

See alsovector() andsetScalar().

void QQuaternion::setVector(qreal x,qreal y,qreal z)

Sets the vector component of this quaternion to (x,y,z).

See alsovector() andsetScalar().

void QQuaternion::setX(qreal x)

Sets the x coordinate of this quaternion's vector to the givenx coordinate.

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

void QQuaternion::setY(qreal y)

Sets the y coordinate of this quaternion's vector to the giveny coordinate.

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

void QQuaternion::setZ(qreal z)

Sets the z coordinate of this quaternion's vector to the givenz coordinate.

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

[static]QQuaternion QQuaternion::slerp(constQQuaternion & q1, constQQuaternion & q2,qreal t)

Interpolates along the shortest spherical path between the rotational positionsq1 andq2. The valuet should be between 0 and 1, indicating the spherical distance to travel betweenq1 andq2.

Ift is less than or equal to 0, thenq1 will be returned. Ift is greater than or equal to 1, thenq2 will be returned.

See alsonlerp().

QVector4D QQuaternion::toVector4D() const

Returns this quaternion as a 4D vector.

QVector3D QQuaternion::vector() const

Returns the vector component of this quaternion.

See alsosetVector() andscalar().

qreal QQuaternion::x() const

Returns the x coordinate of this quaternion's vector.

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

qreal QQuaternion::y() const

Returns the y coordinate of this quaternion's vector.

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

qreal QQuaternion::z() const

Returns the z coordinate of this quaternion's vector.

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

QQuaternion::operator QVariant() const

Returns the quaternion as aQVariant.

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

Multiplies this quaternion's components by the givenfactor, and returns a reference to this quaternion.

See alsooperator/=().

QQuaternion & QQuaternion::operator*=(constQQuaternion & quaternion)

Multiplies this quaternion byquaternion and returns a reference to this quaternion.

QQuaternion & QQuaternion::operator+=(constQQuaternion & quaternion)

Adds the givenquaternion to this quaternion and returns a reference to this quaternion.

See alsooperator-=().

QQuaternion & QQuaternion::operator-=(constQQuaternion & quaternion)

Subtracts the givenquaternion from this quaternion and returns a reference to this quaternion.

See alsooperator+=().

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

Divides this quaternion's components by the givendivisor, and returns a reference to this quaternion.

See alsooperator*=().

Related Non-Members

boolqFuzzyCompare(constQQuaternion & q1, constQQuaternion & q2)

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

booloperator!=(constQQuaternion & q1, constQQuaternion & q2)

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

constQQuaternionoperator*(constQQuaternion & q1, constQQuaternion & q2)

Multipliesq1 andq2 using quaternion multiplication. The result corresponds to applying both of the rotations specified byq1 andq2.

See alsoQQuaternion::operator*=().

constQQuaternionoperator*(qreal factor, constQQuaternion & quaternion)

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

See alsoQQuaternion::operator*=().

constQQuaternionoperator*(constQQuaternion & quaternion,qreal factor)

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

See alsoQQuaternion::operator*=().

constQQuaternionoperator+(constQQuaternion & q1, constQQuaternion & q2)

Returns aQQuaternion object that is the sum of the given quaternions,q1 andq2; each component is added separately.

See alsoQQuaternion::operator+=().

constQQuaternionoperator-(constQQuaternion & q1, constQQuaternion & q2)

Returns aQQuaternion object that is formed by subtractingq2 fromq1; each component is subtracted separately.

See alsoQQuaternion::operator-=().

constQQuaternionoperator-(constQQuaternion & quaternion)

This is an overloaded function.

Returns aQQuaternion object that is formed by changing the sign of all three components of the givenquaternion.

Equivalent toQQuaternion(0,0,0,0) - quaternion.

constQQuaternionoperator/(constQQuaternion & quaternion,qreal divisor)

Returns theQQuaternion object formed by dividing all components of the givenquaternion by the givendivisor.

See alsoQQuaternion::operator/=().

QDataStream &operator<<(QDataStream & stream, constQQuaternion & quaternion)

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

See alsoSerializing Qt Data Types.

booloperator==(constQQuaternion & q1, constQQuaternion & q2)

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

QDataStream &operator>>(QDataStream & stream,QQuaternion & quaternion)

Reads a quaternion from the givenstream into the givenquaternion and returns a reference to the stream.

See alsoSerializing Qt Data Types.

QDataStream &operator>>(QDataStream & stream,QEasingCurve & easing)

Reads an easing curve from the givenstream into the giveneasing curve 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