本页内容

Quaternion QML Type

提供四元数的相关实用函数。更多内容...

Import Statement: import QtQuick3D

方法

  • quaternion fromAxesAndAngles(vector3d axis1, real angle1, vector3d axis2, real angle2)
  • quaternion fromAxesAndAngles(vector3d axis1, real angle1, vector3d axis2, real angle2, vector3d axis3, real angle3)
  • quaternion fromAxisAndAngle(vector3d axis, real angle)
  • quaternion fromAxisAndAngle(real x, real y, real z, real angle)
  • quaternion fromEulerAngles(vector3d eulerAngles)
  • quaternion fromEulerAngles(real x, real y, real z)
  • quaternion lookAt(vector3d sourcePosition, vector3d targetPosition, vector3d forwardDirection, vector3d upDirection)

详细说明

Quaternion 是一个包含实用函数的全局对象。

它不可实例化;要使用它,请直接调用全局对象Quaternion 的成员。例如:

Node {
    rotation: Quaternion.fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45)
}

方法文档

quaternion fromAxesAndAngles(vector3d axis1, real angle1, vector3d axis2, real angle2)

根据axis1 、angle1 、axis2 和angle2 生成一个四元数。返回生成的四元数。

quaternion fromAxesAndAngles(vector3d axis1, real angle1, vector3d axis2, real angle2, vector3d axis3, real angle3)

根据axis1 、angle1 、axis2 、angle2 、axis3 和angle3 生成一个四元数。返回生成的四元数。

quaternion fromAxisAndAngle(vector3d axis, real angle)

根据axis 和angle 创建一个四元数。返回生成的四元数。

quaternion fromAxisAndAngle(real x, real y, real z, real angle)

根据x 、y 、z 和angle 生成一个四元数。返回生成的四元数。

quaternion fromEulerAngles(vector3d eulerAngles)

根据eulerAngles 生成一个四元数。返回生成的四元数。

quaternion fromEulerAngles(real x, real y, real z)

根据x 、y 和z 创建一个四元数。返回生成的四元数。

quaternion lookAt(vector3d sourcePosition, vector3d targetPosition, vector3d forwardDirection, vector3d upDirection)

根据sourcePosition 、targetPosition 、forwardDirection 和upDirection 生成一个四元数。该功能用于获取指向特定目标的旋转值,也可用于将摄像机对准场景中的某个位置。

forwardDirection 默认值为Qt.vector3d(0, 0, -1) ,upDirection 的默认值为Qt.vector3d(0, 1, 0)

返回最终的四元数。

© 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.