vector3d QML Value Type
一个具有 x、y 和 z 属性的值。更多...
| Import Statement: | import QtQuick |
详细说明
vector3d 类型指具有x 、y 和z 属性的值。
vector3d 类型的属性默认具有零向量。此时,x 、y 和z 均设置为0 。
要创建一个 `vector3d ` 值,请将其指定为“x,y,z”字符串:
Rotation { angle: 60; axis: "0,1,0" }或使用Qt.vector3d() 函数:
Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) }或者作为独立的x 、y 和z 分量:
Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 }vector3d 值的每个属性在内部都以单精度浮点数(float )的形式存储。
在与 C++ 集成时,请注意:从 C++ 传递到 QML的任何QVector3D 值都会自动转换为vector3d 值,反之亦然。
vector3d 类型具有以下可在 QML 中调用的幂等函数:
| 函数签名 | 描述 | 示例 |
|---|---|---|
| vector3d crossProduct(vector3d other) | 返回向量 `this ` 与向量 `other ` 进行叉积运算后得到的 `vector3d` 结果 | |
| real dotProduct(vector3d other) | 返回this vector3d与other vector3d的点积结果,该结果为标量real类型 | |
| vector3d times(matrix4x4 matrix) | 返回将this 向量3D与4x4矩阵matrix 进行变换后得到的向量3D结果,该矩阵在向量后应用 | |
| vector3d times(vector3d other) | 返回将this 向量3d与other 向量3d相乘后得到的向量3d结果 | |
| vector3d times(real factor) | 返回将this 向量与标量相乘后的vector3d结果factor | |
| vector3d plus(vector3d other) | 返回将this 向量3d与other 向量3d相加得到的向量3d结果 | |
| vector3d minus(vector3d other) | 返回从 `other vector3d` 中减去 `this vector3d` 后的 `vector3d` 结果 | |
| vector3d normalized() | 返回this 向量的归一化形式 | |
| real length() | 返回this 向量3D长度的标量实数值 | |
| vector2d toVector2d() | 返回将this 向量3d转换为向量2d后的结果 | |
| vector4d toVector4d() | 返回将this vector3d 转换为 vector4d 后的结果 | |
| bool fuzzyEquals(vector3d other, real epsilon) | other如果this 的vector3d与other 的vector3d近似相等,则返回true。当this 的每个属性都处于epsilon 范围内时,该近似关系成立。请注意,epsilon 是可选参数,默认值epsilon 为0.00001。 |
该值类型由QtQuick 导入提供。
另请参阅 QML 值类型。
© 2026 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.