四元数

Quaternion class

四元数通常用于在计算机图形学中执行旋转。

属性

名称描述
w该 w 组件。
xx 分量。
yy 分量。
zz 分量。
标识单位四元数。

方法

constructor

名称描述
constructor()

Result:


constructor_overload

名称描述
constructor_overload(w, x, y, z)初始化 Quaternion 类的新实例。

Parameters:

名称类型描述
w数字四元数的 w 分量
x数字四元数的 x 分量
y数字四元数的 y 分量
z数字四元数的 z 分量

Result:


getLength

名称描述
getLength()获取四元数的长度

Result:


equals

名称描述
equals(obj)检查两个四元数是否相等

Parameters:

名称类型描述
obj对象用于检查相等性的对象。

Result: boolean


hashCode

名称描述
hashCode()获取 Quaternion 的哈希码

Result: 数字


conjugate

名称描述
conjugate()返回当前四元数的共轭四元数

Result: 四元数


inverse

名称描述
inverse()返回当前四元数的逆四元数

Result: 四元数


dot

名称描述
dot(q)点积

Parameters:

名称类型描述
q四元数四元数

Result: 数字


eulerAngles

名称描述
eulerAngles()将四元数转换为欧拉角表示的旋转,所有分量均为弧度

Result: Vector3


normalize

名称描述
normalize()归一化四元数

Result: 四元数


concat

名称描述
concat(rhs)连接两个四元数

Parameters:

名称类型描述
rh四元数null

Result: 四元数


fromAngleAxis

名称描述
fromAngleAxis(a, axis)围绕给定轴创建四元数并顺时针旋转

Parameters:

名称类型描述
a数字顺时针旋转(弧度)
Vector3

Result: 四元数


fromRotation

名称描述
fromRotation(orig, dest)创建一个从原始方向旋转到目标方向的四元数

Parameters:

名称类型描述
origVector3原始方向
destVector3目标方向

Result: 四元数


fromEulerAngle

名称描述
fromEulerAngle(pitch, yaw, roll)根据给定的欧拉角创建四元数

Parameters:

名称类型描述
pitch数字俯仰角(弧度)
yaw数字偏航角(弧度)
滚动数字以弧度表示的滚动

Result: 四元数


fromEulerAngle

名称描述
fromEulerAngle(eulerAngle)根据给定的欧拉角创建四元数

Parameters:

名称类型描述
eulerAngleVector3欧拉角(弧度)

Result: 四元数


toMatrix

名称描述
toMatrix()将四元数表示的旋转转换为变换矩阵。

Result: Matrix4


toString

名称描述
toString()获取四元数的字符串表示

Result: 字符串


interpolate

名称描述
interpolate(t, from, to)在 t 介于 from 和 to 之间时,用给定四元数参数之间的插值填充此四元数。

Parameters:

名称类型描述
t数字用于插值的系数。
from四元数源四元数。
to四元数目标四元数。

Result: 四元数