On this page
vector3d QML Basic Type
The vector3d
type refers to a value with x
, y
, and z
attributes.
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 this vector3d with the other vector3d |
|
real dotProduct(vector3d other) | Returns the scalar real result of the dot product of this vector3d with the other vector3d |
|
vector3d times(matrix4x4 matrix) | Returns the vector3d result of transforming this vector3d with the 4x4 matrix with the matrix applied post-vector |
|
vector3d times(vector3d other) | Returns the vector3d result of multiplying this vector3d with the other vector3d |
|
vector3d times(real factor) | Returns the vector3d result of multiplying this vector3d with the scalar factor |
|
vector3d plus(vector3d other) | Returns the vector3d result of the addition of this vector3d with the other vector3d |
|
vector3d minus(vector3d other) | Returns the vector3d result of the subtraction of other vector3d from this vector3d |
|
vector3d normalized() | Returns the normalized form of this vector |
|
real length() | Returns the scalar real value of the length of this vector3d |
|
vector2d toVector2d() | Returns the vector2d result of converting this vector3d to a vector2d |
|
vector4d toVector4d() | Returns the vector4d result of converting this vector3d to a vector4d |
|
bool fuzzyEquals(vector3d other, real epsilon) | Returns true if this vector3d is approximately equal to the other vector3d. 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. |
|
This basic type is provided by the QtQuick import.
See also QML Basic Types.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.15/qml-vector3d.html