Skip to content

Quaternion

本文档由 src/stdlib/quaternion.mcrs 自动生成,请勿手动编辑。

API 列表


quat_identity_w v2.0.0

单位四元数 (0,0,0,1) 的 W 分量

redscript
fn quat_identity_w(): int

返回: 10000


quat_identity_x v2.0.0

单位四元数的 X 分量

redscript
fn quat_identity_x(): int

返回: 0


quat_identity_y v2.0.0

单位四元数的 Y 分量

redscript
fn quat_identity_y(): int

返回: 0


quat_identity_z v2.0.0

单位四元数的 Z 分量

redscript
fn quat_identity_z(): int

返回: 0


quat_axis_x_x v2.0.0

绕 X 轴旋转 angle_deg° 的四元数 X 分量

redscript
fn quat_axis_x_x(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(整数,度)

返回: sin(angle/2) ×10000


quat_axis_x_y v2.0.0

绕 X 轴旋转 angle_deg° 的四元数 Y 分量

redscript
fn quat_axis_x_y(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: 0


quat_axis_x_z v2.0.0

绕 X 轴旋转 angle_deg° 的四元数 Z 分量

redscript
fn quat_axis_x_z(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: 0


quat_axis_x_w v2.0.0

绕 X 轴旋转 angle_deg° 的四元数 W 分量

redscript
fn quat_axis_x_w(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: cos(angle/2) ×10000


quat_axis_y_x v2.0.0

绕 Y 轴旋转 angle_deg° 的四元数 X 分量

redscript
fn quat_axis_y_x(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: 0


quat_axis_y_y v2.0.0

绕 Y 轴旋转 angle_deg° 的四元数 Y 分量

redscript
fn quat_axis_y_y(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: sin(angle/2) ×10000


quat_axis_y_z v2.0.0

绕 Y 轴旋转 angle_deg° 的四元数 Z 分量

redscript
fn quat_axis_y_z(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: 0


quat_axis_y_w v2.0.0

绕 Y 轴旋转 angle_deg° 的四元数 W 分量

redscript
fn quat_axis_y_w(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: cos(angle/2) ×10000


quat_axis_z_x v2.0.0

绕 Z 轴旋转 angle_deg° 的四元数 X 分量

redscript
fn quat_axis_z_x(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: 0


quat_axis_z_y v2.0.0

绕 Z 轴旋转 angle_deg° 的四元数 Y 分量

redscript
fn quat_axis_z_y(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: 0


quat_axis_z_z v2.0.0

绕 Z 轴旋转 angle_deg° 的四元数 Z 分量

redscript
fn quat_axis_z_z(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: sin(angle/2) ×10000


quat_axis_z_w v2.0.0

绕 Z 轴旋转 angle_deg° 的四元数 W 分量

redscript
fn quat_axis_z_w(angle_deg: int): int

参数

参数说明
angle_deg旋转角度(度)

返回: cos(angle/2) ×10000


quat_mul_x v2.0.0

四元数乘积 a×b 的 X 分量(所有分量 ×10000)

redscript
fn quat_mul_x(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): int

参数

参数说明
ax@param ay @param az @param aw Quaternion a components ×10000
bx@param by @param bz @param bw Quaternion b components ×10000

返回: (a×b) 的 X 分量 ×10000

示例

redscript
let rx: int = quat_mul_x(ax, ay, az, aw, bx, by, bz, bw)

quat_mul_y v2.0.0

四元数乘积 a×b 的 Y 分量

redscript
fn quat_mul_y(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): int

参数

参数说明
ax@param ay @param az @param aw Quaternion a components ×10000
bx@param by @param bz @param bw Quaternion b components ×10000

返回: (a×b) 的 Y 分量 ×10000


quat_mul_z v2.0.0

四元数乘积 a×b 的 Z 分量

redscript
fn quat_mul_z(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): int

参数

参数说明
ax@param ay @param az @param aw Quaternion a components ×10000
bx@param by @param bz @param bw Quaternion b components ×10000

返回: (a×b) 的 Z 分量 ×10000


quat_mul_w v2.0.0

四元数乘积 a×b 的 W 分量

redscript
fn quat_mul_w(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): int

参数

参数说明
ax@param ay @param az @param aw Quaternion a components ×10000
bx@param by @param bz @param bw Quaternion b components ×10000

返回: (a×b) 的 W 分量 ×10000


quat_conj_x v2.0.0

四元数共轭的 X 分量

redscript
fn quat_conj_x(qx: int, qy: int, qz: int, qw: int): int

参数

参数说明
qx@param qy @param qz @param qw Input quaternion ×10000

返回: -qx


quat_conj_y v2.0.0

四元数共轭的 Y 分量

redscript
fn quat_conj_y(qx: int, qy: int, qz: int, qw: int): int

参数

参数说明
qx@param qy @param qz @param qw Input quaternion ×10000

返回: -qy


quat_conj_z v2.0.0

四元数共轭的 Z 分量

redscript
fn quat_conj_z(qx: int, qy: int, qz: int, qw: int): int

参数

参数说明
qx@param qy @param qz @param qw Input quaternion ×10000

返回: -qz


quat_conj_w v2.0.0

四元数共轭的 W 分量(不变)

redscript
fn quat_conj_w(qx: int, qy: int, qz: int, qw: int): int

参数

参数说明
qx@param qy @param qz @param qw Input quaternion ×10000

返回: qw


quat_mag_sq v2.0.0

四元数的模平方(×10000);单位四元数应等于 10000

redscript
fn quat_mag_sq(qx: int, qy: int, qz: int, qw: int): int

参数

参数说明
qx@param qy @param qz @param qw Quaternion components ×10000

返回: qx²/10000 + qy²/10000 + qz²/10000 + qw²/10000


quat_dot v2.0.0

两个四元数的点积(×10000)

redscript
fn quat_dot(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): int

参数

参数说明
ax@param ay @param az @param aw Quaternion a ×10000
bx@param by @param bz @param bw Quaternion b ×10000

返回: axbx/10000 + ayby/10000 + azbz/10000 + awbw/10000


quat_slerp_x v2.0.0

两个四元数在 t/1000 处球面线性插值的 X 分量(LERP + 归一化近似)

redscript
fn quat_slerp_x(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int, t: int): int

参数

参数说明
ax@param ay @param az @param aw Start quaternion ×10000
bx@param by @param bz @param bw End quaternion ×10000
t插值系数 ×1000(0=a,1000=b)

返回: 插值四元数的 X 分量 ×10000

示例

redscript
let rx: int = quat_slerp_x(ax, ay, az, aw, bx, by, bz, bw, 500)

quat_slerp_y v2.0.0

两个四元数在 t/1000 处球面线性插值的 Y 分量

redscript
fn quat_slerp_y(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int, t: int): int

参数

参数说明
ax@param ay @param az @param aw Start quaternion ×10000
bx@param by @param bz @param bw End quaternion ×10000
tInterpolation factor ×1000

返回: 插值四元数的 Y 分量 ×10000


quat_slerp_z v2.0.0

两个四元数在 t/1000 处球面线性插值的 Z 分量

redscript
fn quat_slerp_z(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int, t: int): int

参数

参数说明
ax@param ay @param az @param aw Start quaternion ×10000
bx@param by @param bz @param bw End quaternion ×10000
tInterpolation factor ×1000

返回: 插值四元数的 Z 分量 ×10000


quat_slerp_w v2.0.0

两个四元数在 t/1000 处球面线性插值的 W 分量

redscript
fn quat_slerp_w(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int, t: int): int

参数

参数说明
ax@param ay @param az @param aw Start quaternion ×10000
bx@param by @param bz @param bw End quaternion ×10000
tInterpolation factor ×1000

返回: 插值四元数的 W 分量 ×10000


quat_euler_x v2.0.0

欧拉角(YXZ 顺序,MC 约定)转换为四元数的 X 分量

redscript
fn quat_euler_x(yaw: int, pitch: int, roll: int): int

参数

参数说明
yawY 轴旋转(度)
pitchX 轴旋转(度)
rollZ 轴旋转(度)

返回: X 分量 ×10000

示例

redscript
let qx: int = quat_euler_x(90, 0, 0)

quat_euler_y v2.0.0

欧拉角(YXZ 顺序)转换为四元数的 Y 分量

redscript
fn quat_euler_y(yaw: int, pitch: int, roll: int): int

参数

参数说明
yawY 轴旋转(度)
pitchX 轴旋转(度)
rollZ 轴旋转(度)

返回: Y 分量 ×10000


quat_euler_z v2.0.0

欧拉角(YXZ 顺序)转换为四元数的 Z 分量

redscript
fn quat_euler_z(yaw: int, pitch: int, roll: int): int

参数

参数说明
yawY 轴旋转(度)
pitchX 轴旋转(度)
rollZ 轴旋转(度)

返回: Z 分量 ×10000


quat_euler_w v2.0.0

欧拉角(YXZ 顺序)转换为四元数的 W 分量

redscript
fn quat_euler_w(yaw: int, pitch: int, roll: int): int

参数

参数说明
yawY 轴旋转(度)
pitchX 轴旋转(度)
rollZ 轴旋转(度)

返回: W 分量 ×10000


Released under the MIT License.