quaternion QML Value Type
A quaternion type has scalar, x, y, and z attributes. More...
Detailed Description
A quaternion
type has scalar
, x
, y
and z
attributes.
To create a quaternion
value, specify it as a "scalar,x,y,z" string, or define the components individually, or compose it with the Qt.quaternion() function.
The quaternion type has the following idempotent functions which can be invoked in QML:
Function Signature | Description | Example |
---|---|---|
real dotProduct(quaternion other) | Returns the scalar real result of the dot product of this quaternion with the other quaternion | |
quaternion times(quaternion other) | Returns the quaternion result of multiplying this quaternion with the other quaternion, which corresponds to applying both of the rotations | |
vector3d times(vector3d vector) | Returns the vector3d result of rotating the vector with this quaternion | |
quaternion times(real factor) | Returns the quaternion result of multiplying this quaternion with the scalar factor | var a = Qt.quaternion(1,2,3,4); var b = 4.48; var c = a.times(b); console.log(c.toString()); // QQuaternion(4.48, 8.96, 13.44, 17.92) |
quaternion plus(quaternion other) | Returns the quaternion result of the addition of this quaternion with the other quaternion | |
quaternion minus(quaternion other) | Returns the quaternion result of the subtraction of other quaternion from this quaternion | |
quaternion normalized() | Returns the normalized unit form of this quaternion | var a = Qt.quaternion(1,2,3,4); var b = a.normalized(); console.log(b.toString()); // QQuaternion(0.182574, 0.365148, 0.547723, 0.730297) |
quaternion inverted() | Returns the inverse of this quaternion | var a = Qt.quaternion(0.5,0.5,0.5,-0.5); var b = a.inverted(); console.log(b.toString()); // QQuaternion(0.5, -0.5, -0.5, 0.5) |
quaternion conjugated() | Returns the conjugate of this quaternion | var a = Qt.quaternion(1,2,3,4); var b = a.conjugated() console.log(b.toString()); // QQuaternion(1, -2, -3, -4) |
real length() | Returns the scalar real value of the length of this quaternion | var a = Qt.quaternion(1,2,3,4); var b = a.length(); console.log(b.toString()); // 5.477225575051661 |
vector3d toEulerAngles() | Returns the vector3d Euler angles (in degrees) that corresponds to this quaternion | var a = Qt.quaternion(0.933012,0.25,-0.25,0.066987); var b = a.toEulerAngles(); console.log(b.toString()); // QVector3D(30, -30, -4.28846e-05) |
vector4d toVector4d() | Returns the vector4d result of converting this quaternion to a vector4d | var a = Qt.quaternion(1,2,3,4); var b = a.toVector4d(); console.log(b.toString()); // QVector4D(2, 3, 4, 1) |
bool fuzzyEquals(quaternion other, real epsilon) | Returns true if this quaternion is approximately equal to the other quaternion. The approximation will be true if each attribute of this is within epsilon of other . Note that epsilon is an optional argument, the default epsilon is 0.00001. |
Properties of type quaternion
have Qt.quaternion(1, 0, 0, 0)
as their default value.
This value type is provided by the QtQuick import.
See also QML Value Types.
© 2024 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 the GNU 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.