vector3d QML Value Type
a value with x, y, and z attributes. More...
Detailed Description
The vector3d type refers to a value with x, y, and z attributes.
Properties of type vector3d have a zero vector by default. This has x, y and z set to 0.
To create a vector3d value, specify it as a "x,y,z" string:
Rotation { angle: 60; axis: "0,1,0" }
or with the Qt.vector3d() function:
Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) }
or as separate x, y, and z components:
Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 }
Each attribute of a vector3d value is stored internally as a single-precision floating point number (float).
When integrating with C++, note that any QVector3D value passed into QML from C++ is automatically converted into a vector3d value, and vice-versa.
The vector3d type has the following idempotent functions which can be invoked in QML:
| Function Signature | Description | Example | 
|---|---|---|
| vector3d crossProduct(vector3d other) | Returns the vector3d result of the cross product of thisvector3d with theothervector3d | |
| real dotProduct(vector3d other) | Returns the scalar real result of the dot product of thisvector3d with theothervector3d | |
| vector3d times(matrix4x4 matrix) | Returns the vector3d result of transforming thisvector3d with the 4x4matrixwith the matrix applied post-vector | |
| vector3d times(vector3d other) | Returns the vector3d result of multiplying thisvector3d with theothervector3d | |
| vector3d times(real factor) | Returns the vector3d result of multiplying thisvector3d with the scalarfactor | var a = Qt.vector3d(1,2,3); var b = 4.48; var c = a.times(b); console.log(c.toString()); // QVector3D(4.48, 8.96, 13.44) | 
| vector3d plus(vector3d other) | Returns the vector3d result of the addition of thisvector3d with theothervector3d | |
| vector3d minus(vector3d other) | Returns the vector3d result of the subtraction of othervector3d fromthisvector3d | |
| vector3d normalized() | Returns the normalized form of thisvector | var a = Qt.vector3d(1,2,3); var b = a.normalized(); console.log(b.toString()); // QVector3D(0.267261, 0.534522, 0.801784) | 
| real length() | Returns the scalar real value of the length of thisvector3d | var a = Qt.vector3d(1,2,3); var b = a.length(); console.log(b.toString()); // 3.7416573867739413 | 
| vector2d toVector2d() | Returns the vector2d result of converting thisvector3d to a vector2d | var a = Qt.vector3d(1,2,3); var b = a.toVector2d(); console.log(b.toString()); // QVector2D(1, 2) | 
| vector4d toVector4d() | Returns the vector4d result of converting thisvector3d to a vector4d | var a = Qt.vector3d(1,2,3); var b = a.toVector4d(); console.log(b.toString()); // QVector4D(1, 2, 3, 0) | 
| bool fuzzyEquals(vector3d other, real epsilon) | Returns true if thisvector3d is approximately equal to theothervector3d. The approximation will be true if each attribute ofthisis withinepsilonofother. Note thatepsilonis an optional argument, the defaultepsilonis 0.00001. | 
This value type is provided by the QtQuick import.
See also QML Value Types.
© 2025 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.
