QQuaternionclass represents a quaternion consisting of a vector and scalar. 更多 …
4.6 版新增。
def
__add__
(, q2)
def
__div__
(, divisor)
def
__eq__
(, q2)
def
__iadd__
(quaternion)
def
__idiv__
(divisor)
def
__imul__
(factor)
def
__imul__
(quaternion)
def
__isub__
(quaternion)
def
__mul__
(, factor)
def
__mul__
(, q2)
def
__mul__
(factor)
def
__ne__
(, q2)
def
__reduce__
()
def
__repr__
()
def
__sub__
()
def
__sub__
(, q2)
def
conjugate
()
def
conjugated
()
def
getAxes
(xAxis, yAxis, zAxis)
def
inverted
()
def
isIdentity
()
def
isNull
()
def
length
()
def
lengthSquared
()
def
normalize
()
def
normalized
()
def
rotatedVector
(vector)
def
scalar
()
def
setScalar
(scalar)
def
setVector
(vector)
def
setVector
(x, y, z)
def
setX
(x)
def
setY
(y)
def
setZ
(z)
def
toEulerAngles
()
def
toRotationMatrix
()
def
toVector4D
()
def
vector
()
def
x
()
def
y
()
def
z
()
def
dotProduct
(q1, q2)
def
fromAxes
(xAxis, yAxis, zAxis)
def
fromAxisAndAngle
(axis, angle)
def
fromAxisAndAngle
(x, y, z, angle)
def
fromDirection
(direction, up)
def
fromEulerAngles
(eulerAngles)
def
fromEulerAngles
(pitch, yaw, roll)
def
fromRotationMatrix
(rot3x3)
def
nlerp
(q1, q2, t)
def
rotationTo
(from, to)
def
slerp
(q1, q2, t)
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.
QQuaternion
¶
QQuaternion(vector)
QQuaternion(scalar, vector)
QQuaternion(scalar, xpos, ypos, zpos)
- param ypos
float- param scalar
float- param zpos
float- param vector
- param xpos
float
Constructs an identity quaternion (1, 0, 0, 0), i.e. with the vector (0, 0, 0) and scalar 1.
Constructs a quaternion vector from the specified
vector
and
scalar
.
Constructs a quaternion with the vector (
xpos
,
ypos
,
zpos
) and
scalar
.
PySide2.QtGui.QQuaternion.
__reduce__
(
)
¶
PyObject
PySide2.QtGui.QQuaternion.
__repr__
(
)
¶
PyObject
PySide2.QtGui.QQuaternion.
conjugate
(
)
¶
注意
此函数被弃用。
使用
conjugated()
代替。
PySide2.QtGui.QQuaternion.
conjugated
(
)
¶
Returns the conjugate of this quaternion, which is (-x, -y, -z, scalar).
PySide2.QtGui.QQuaternion.
dotProduct
(
q1
,
q2
)
¶
q1
–
QQuaternion
q2
–
QQuaternion
float
Returns the dot product of
q1
and
q2
.
另请参阅
PySide2.QtGui.QQuaternion.
fromAxes
(
xAxis
,
yAxis
,
zAxis
)
¶
Constructs the quaternion using 3 axes (
xAxis
,
yAxis
,
zAxis
).
注意
The axes are assumed to be orthonormal.
PySide2.QtGui.QQuaternion.
fromAxisAndAngle
(
axis
,
angle
)
¶
axis
–
QVector3D
angle
–
float
Creates a normalized quaternion that corresponds to rotating through
angle
degrees about the specified 3D
axis
.
另请参阅
getAxisAndAngle()
PySide2.QtGui.QQuaternion.
fromAxisAndAngle
(
x
,
y
,
z
,
angle
)
¶
x
–
float
y
–
float
z
–
float
angle
–
float
Creates a normalized quaternion that corresponds to rotating through
angle
degrees about the 3D axis (
x
,
y
,
z
).
另请参阅
getAxisAndAngle()
PySide2.QtGui.QQuaternion.
fromDirection
(
direction
,
up
)
¶
Constructs the quaternion using specified forward direction
direction
and upward direction
up
. If the upward direction was not specified or the forward and upward vectors are collinear, a new orthonormal upward direction will be generated.
另请参阅
PySide2.QtGui.QQuaternion.
fromEulerAngles
(
eulerAngles
)
¶
eulerAngles
–
QVector3D
这是重载函数。
Creates a quaternion that corresponds to a rotation of
eulerAngles
: eulerAngles.
z()
degrees around the z axis, eulerAngles.
x()
degrees around the x axis, and eulerAngles.
y()
degrees around the y axis (in that order).
另请参阅
PySide2.QtGui.QQuaternion.
fromEulerAngles
(
pitch
,
yaw
,
roll
)
¶
pitch
–
float
yaw
–
float
roll
–
float
Creates a quaternion that corresponds to a rotation of
roll
degrees around the z axis,
pitch
degrees around the x axis, and
yaw
degrees around the y axis (in that order).
另请参阅
getEulerAngles()
PySide2.QtGui.QQuaternion.
fromRotationMatrix
(
rot3x3
)
¶
rot3x3
–
QMatrix3x3
Creates a quaternion that corresponds to a rotation matrix
rot3x3
.
注意
If a given rotation matrix is not normalized, the resulting quaternion will contain scaling information.
PySide2.QtGui.QQuaternion.
getAxes
(
xAxis
,
yAxis
,
zAxis
)
¶
Returns the 3 orthonormal axes (
xAxis
,
yAxis
,
zAxis
) defining the quaternion.
PySide2.QtGui.QQuaternion.
inverted
(
)
¶
Returns the inverse of this quaternion. If this quaternion is null, then a null quaternion is returned.
PySide2.QtGui.QQuaternion.
isIdentity
(
)
¶
bool
返回
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
.
PySide2.QtGui.QQuaternion.
isNull
(
)
¶
bool
返回
true
if the x, y, z, and scalar components of this quaternion are set to 0.0; otherwise returns
false
.
PySide2.QtGui.QQuaternion.
length
(
)
¶
float
Returns the length of the quaternion. This is also called the “norm”.
PySide2.QtGui.QQuaternion.
lengthSquared
(
)
¶
float
Returns the squared length of the quaternion.
另请参阅
PySide2.QtGui.QQuaternion.
nlerp
(
q1
,
q2
,
t
)
¶
q1
–
QQuaternion
q2
–
QQuaternion
t
–
float
Interpolates along the shortest linear path between the rotational positions
q1
and
q2
。值
t
should be between 0 and 1, indicating the distance to travel between
q1
and
q2
. The result will be
normalized()
.
若
t
is less than or equal to 0, then
q1
will be returned. If
t
is greater than or equal to 1, then
q2
将被返回。
The function is typically faster than
slerp()
and will give approximate results to spherical interpolation that are good enough for some applications.
另请参阅
PySide2.QtGui.QQuaternion.
normalize
(
)
¶
Normalizes the current quaternion in place. Nothing happens if this is a null quaternion or the length of the quaternion is very close to 1.
另请参阅
PySide2.QtGui.QQuaternion.
normalized
(
)
¶
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.
PySide2.QtGui.QQuaternion.
__ne__
(
q2
)
¶
q2
–
QQuaternion
bool
PySide2.QtGui.QQuaternion.
__mul__
(
q2
)
¶
q2
–
QQuaternion
PySide2.QtGui.QQuaternion.
__mul__
(
factor
)
¶
factor
–
float
PySide2.QtGui.QQuaternion.
__mul__
(
factor
)
¶
factor
–
float
PySide2.QtGui.QQuaternion.
__imul__
(
quaternion
)
¶
quaternion
–
QQuaternion
PySide2.QtGui.QQuaternion.
__imul__
(
factor
)
¶
factor
–
float
Multiplies this quaternion’s components by the given
factor
, and returns a reference to this quaternion.
另请参阅
operator/=()
PySide2.QtGui.QQuaternion.
__add__
(
q2
)
¶
q2
–
QQuaternion
PySide2.QtGui.QQuaternion.
__iadd__
(
quaternion
)
¶
quaternion
–
QQuaternion
添加给定
quaternion
to this quaternion and returns a reference to this quaternion.
另请参阅
operator-=()
PySide2.QtGui.QQuaternion.
__sub__
(
)
¶
PySide2.QtGui.QQuaternion.
__sub__
(
q2
)
¶
q2
–
QQuaternion
PySide2.QtGui.QQuaternion.
__isub__
(
quaternion
)
¶
quaternion
–
QQuaternion
Subtracts the given
quaternion
from this quaternion and returns a reference to this quaternion.
另请参阅
operator+=()
PySide2.QtGui.QQuaternion.
__div__
(
divisor
)
¶
divisor
–
float
PySide2.QtGui.QQuaternion.
__idiv__
(
divisor
)
¶
divisor
–
float
Divides this quaternion’s components by the given
divisor
, and returns a reference to this quaternion.
另请参阅
operator*=()
PySide2.QtGui.QQuaternion.
__eq__
(
q2
)
¶
q2
–
QQuaternion
bool
PySide2.QtGui.QQuaternion.
rotatedVector
(
vector
)
¶
Rotates
vector
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.conjugated()).vector();
PySide2.QtGui.QQuaternion.
rotationTo
(
from
,
to
)
¶
Returns the shortest arc quaternion to rotate from the direction described by the vector
from
to the direction described by the vector
to
.
另请参阅
PySide2.QtGui.QQuaternion.
scalar
(
)
¶
float
Returns the scalar component of this quaternion.
另请参阅
PySide2.QtGui.QQuaternion.
setScalar
(
scalar
)
¶
scalar
–
float
Sets the scalar component of this quaternion to
scalar
.
PySide2.QtGui.QQuaternion.
setVector
(
vector
)
¶
vector
–
QVector3D
Sets the vector component of this quaternion to
vector
.
另请参阅
PySide2.QtGui.QQuaternion.
setVector
(
x
,
y
,
z
)
¶
x
–
float
y
–
float
z
–
float
Sets the vector component of this quaternion to (
x
,
y
,
z
).
另请参阅
PySide2.QtGui.QQuaternion.
setX
(
x
)
¶
x
–
float
Sets the x coordinate of this quaternion’s vector to the given
x
坐标。
另请参阅
PySide2.QtGui.QQuaternion.
setY
(
y
)
¶
y
–
float
Sets the y coordinate of this quaternion’s vector to the given
y
坐标。
另请参阅
PySide2.QtGui.QQuaternion.
setZ
(
z
)
¶
z
–
float
Sets the z coordinate of this quaternion’s vector to the given
z
坐标。
另请参阅
PySide2.QtGui.QQuaternion.
slerp
(
q1
,
q2
,
t
)
¶
q1
–
QQuaternion
q2
–
QQuaternion
t
–
float
Interpolates along the shortest spherical path between the rotational positions
q1
and
q2
。值
t
should be between 0 and 1, indicating the spherical distance to travel between
q1
and
q2
.
若
t
is less than or equal to 0, then
q1
will be returned. If
t
is greater than or equal to 1, then
q2
将被返回。
另请参阅
PySide2.QtGui.QQuaternion.
toEulerAngles
(
)
¶
这是重载函数。
Calculates roll, pitch, and yaw Euler angles (in degrees) that corresponds to this quaternion.
另请参阅
PySide2.QtGui.QQuaternion.
toRotationMatrix
(
)
¶
Creates a rotation matrix that corresponds to this quaternion.
注意
If this quaternion is not normalized, the resulting rotation matrix will contain scaling information.
PySide2.QtGui.QQuaternion.
vector
(
)
¶
Returns the vector component of this quaternion.
另请参阅
PySide2.QtGui.QQuaternion.
x
(
)
¶
float
Returns the x coordinate of this quaternion’s vector.
PySide2.QtGui.QQuaternion.
y
(
)
¶
float
Returns the y coordinate of this quaternion’s vector.
PySide2.QtGui.QQuaternion.
z
(
)
¶
float
Returns the z coordinate of this quaternion’s vector.