Skip to content

Quaternion

Auto-generated from src/stdlib/quaternion.mcrs — do not edit manually.

API


quat_identity_w v2.0.0

W component of the identity quaternion (0, 0, 0, 1).

redscript
fn quat_identity_w(): int

Returns: 10000


quat_identity_x v2.0.0

X component of the identity quaternion.

redscript
fn quat_identity_x(): int

Returns: 0


quat_identity_y v2.0.0

Y component of the identity quaternion.

redscript
fn quat_identity_y(): int

Returns: 0


quat_identity_z v2.0.0

Z component of the identity quaternion.

redscript
fn quat_identity_z(): int

Returns: 0


quat_axis_x_x v2.0.0

X component of a quaternion representing rotation by angle_deg around the X axis.

redscript
fn quat_axis_x_x(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees (integer)

Returns: sin(angle/2) ×10000


quat_axis_x_y v2.0.0

Y component of a quaternion representing rotation by angle_deg around the X axis.

redscript
fn quat_axis_x_y(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: 0


quat_axis_x_z v2.0.0

Z component of a quaternion representing rotation by angle_deg around the X axis.

redscript
fn quat_axis_x_z(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: 0


quat_axis_x_w v2.0.0

W component of a quaternion representing rotation by angle_deg around the X axis.

redscript
fn quat_axis_x_w(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: cos(angle/2) ×10000


quat_axis_y_x v2.0.0

X component of a quaternion representing rotation by angle_deg around the Y axis.

redscript
fn quat_axis_y_x(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: 0


quat_axis_y_y v2.0.0

Y component of a quaternion representing rotation by angle_deg around the Y axis.

redscript
fn quat_axis_y_y(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: sin(angle/2) ×10000


quat_axis_y_z v2.0.0

Z component of a quaternion representing rotation by angle_deg around the Y axis.

redscript
fn quat_axis_y_z(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: 0


quat_axis_y_w v2.0.0

W component of a quaternion representing rotation by angle_deg around the Y axis.

redscript
fn quat_axis_y_w(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: cos(angle/2) ×10000


quat_axis_z_x v2.0.0

X component of a quaternion representing rotation by angle_deg around the Z axis.

redscript
fn quat_axis_z_x(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: 0


quat_axis_z_y v2.0.0

Y component of a quaternion representing rotation by angle_deg around the Z axis.

redscript
fn quat_axis_z_y(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: 0


quat_axis_z_z v2.0.0

Z component of a quaternion representing rotation by angle_deg around the Z axis.

redscript
fn quat_axis_z_z(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: sin(angle/2) ×10000


quat_axis_z_w v2.0.0

W component of a quaternion representing rotation by angle_deg around the Z axis.

redscript
fn quat_axis_z_w(angle_deg: int): int

Parameters

ParameterDescription
angle_degRotation angle in degrees

Returns: cos(angle/2) ×10000


quat_mul_x v2.0.0

X component of quaternion product a × b.

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Quaternion a components ×10000
bx@param by @param bz @param bw Quaternion b components ×10000

Returns: X component of a × b ×10000

Example

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

quat_mul_y v2.0.0

Y component of quaternion product a × b.

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Quaternion a components ×10000
bx@param by @param bz @param bw Quaternion b components ×10000

Returns: Y component of a × b ×10000


quat_mul_z v2.0.0

Z component of quaternion product a × b.

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Quaternion a components ×10000
bx@param by @param bz @param bw Quaternion b components ×10000

Returns: Z component of a × b ×10000


quat_mul_w v2.0.0

W component of quaternion product a × b.

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Quaternion a components ×10000
bx@param by @param bz @param bw Quaternion b components ×10000

Returns: W component of a × b ×10000


quat_conj_x v2.0.0

X component of the conjugate of quaternion (qx, qy, qz, qw).

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

Parameters

ParameterDescription
qx@param qy @param qz @param qw Input quaternion ×10000

Returns: -qx


quat_conj_y v2.0.0

Y component of the conjugate of quaternion (qx, qy, qz, qw).

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

Parameters

ParameterDescription
qx@param qy @param qz @param qw Input quaternion ×10000

Returns: -qy


quat_conj_z v2.0.0

Z component of the conjugate of quaternion (qx, qy, qz, qw).

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

Parameters

ParameterDescription
qx@param qy @param qz @param qw Input quaternion ×10000

Returns: -qz


quat_conj_w v2.0.0

W component of the conjugate of quaternion (qx, qy, qz, qw).

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

Parameters

ParameterDescription
qx@param qy @param qz @param qw Input quaternion ×10000

Returns: qw (unchanged)


quat_mag_sq v2.0.0

Magnitude squared of a quaternion in ×10000 scale.

For a unit quaternion this should equal 10000.

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

Parameters

ParameterDescription
qx@param qy @param qz @param qw Quaternion components ×10000

Returns: qx²/10000 + qy²/10000 + qz²/10000 + qw²/10000 (×10000)


quat_dot v2.0.0

Dot product of two quaternions in ×10000 scale.

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Quaternion a ×10000
bx@param by @param bz @param bw Quaternion b ×10000

Returns: ax*bx/10000 + ay*by/10000 + az*bz/10000 + aw*bw/10000


quat_slerp_x v2.0.0

X component of the SLERP interpolation between quaternions a and b at t/1000.

Uses LERP + normalise (good approximation for small angles).

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Start quaternion ×10000
bx@param by @param bz @param bw End quaternion ×10000
tInterpolation factor ×1000 (0 = a, 1000 = b)

Returns: X component of interpolated quaternion ×10000

Example

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

quat_slerp_y v2.0.0

Y component of the SLERP interpolation between quaternions a and b at t/1000.

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Start quaternion ×10000
bx@param by @param bz @param bw End quaternion ×10000
tInterpolation factor ×1000

Returns: Y component of interpolated quaternion ×10000


quat_slerp_z v2.0.0

Z component of the SLERP interpolation between quaternions a and b at t/1000.

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Start quaternion ×10000
bx@param by @param bz @param bw End quaternion ×10000
tInterpolation factor ×1000

Returns: Z component of interpolated quaternion ×10000


quat_slerp_w v2.0.0

W component of the SLERP interpolation between quaternions a and b at t/1000.

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

Parameters

ParameterDescription
ax@param ay @param az @param aw Start quaternion ×10000
bx@param by @param bz @param bw End quaternion ×10000
tInterpolation factor ×1000

Returns: W component of interpolated quaternion ×10000


quat_euler_x v2.0.0

X component of the quaternion from Euler angles (YXZ order, MC convention).

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

Parameters

ParameterDescription
yawY-axis rotation in degrees
pitchX-axis rotation in degrees
rollZ-axis rotation in degrees

Returns: X component ×10000

Example

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

quat_euler_y v2.0.0

Y component of the quaternion from Euler angles (YXZ order, MC convention).

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

Parameters

ParameterDescription
yawY-axis rotation in degrees
pitchX-axis rotation in degrees
rollZ-axis rotation in degrees

Returns: Y component ×10000


quat_euler_z v2.0.0

Z component of the quaternion from Euler angles (YXZ order, MC convention).

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

Parameters

ParameterDescription
yawY-axis rotation in degrees
pitchX-axis rotation in degrees
rollZ-axis rotation in degrees

Returns: Z component ×10000


quat_euler_w v2.0.0

W component of the quaternion from Euler angles (YXZ order, MC convention).

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

Parameters

ParameterDescription
yawY-axis rotation in degrees
pitchX-axis rotation in degrees
rollZ-axis rotation in degrees

Returns: W component ×10000


Released under the MIT License.