Quaternion
Auto-generated from
src/stdlib/quaternion.mcrs— do not edit manually.
API
- quat_identity_w
- quat_identity_x
- quat_identity_y
- quat_identity_z
- quat_axis_x_x
- quat_axis_x_y
- quat_axis_x_z
- quat_axis_x_w
- quat_axis_y_x
- quat_axis_y_y
- quat_axis_y_z
- quat_axis_y_w
- quat_axis_z_x
- quat_axis_z_y
- quat_axis_z_z
- quat_axis_z_w
- quat_mul_x
- quat_mul_y
- quat_mul_z
- quat_mul_w
- quat_conj_x
- quat_conj_y
- quat_conj_z
- quat_conj_w
- quat_mag_sq
- quat_dot
- quat_slerp_x
- quat_slerp_y
- quat_slerp_z
- quat_slerp_w
- quat_euler_x
- quat_euler_y
- quat_euler_z
- quat_euler_w
quat_identity_w v2.0.0
W component of the identity quaternion (0, 0, 0, 1).
fn quat_identity_w(): intReturns: 10000
quat_identity_x v2.0.0
X component of the identity quaternion.
fn quat_identity_x(): intReturns: 0
quat_identity_y v2.0.0
Y component of the identity quaternion.
fn quat_identity_y(): intReturns: 0
quat_identity_z v2.0.0
Z component of the identity quaternion.
fn quat_identity_z(): intReturns: 0
quat_axis_x_x v2.0.0
X component of a quaternion representing rotation by angle_deg around the X axis.
fn quat_axis_x_x(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_x_y(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_x_z(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_x_w(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_y_x(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_y_y(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_y_z(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_y_w(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_z_x(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_z_y(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_z_z(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation 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.
fn quat_axis_z_w(angle_deg: int): intParameters
| Parameter | Description |
|---|---|
angle_deg | Rotation angle in degrees |
Returns: cos(angle/2) ×10000
quat_mul_x v2.0.0
X component of quaternion product a × b.
fn quat_mul_x(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): intParameters
| Parameter | Description |
|---|---|
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
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.
fn quat_mul_y(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): intParameters
| Parameter | Description |
|---|---|
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.
fn quat_mul_z(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): intParameters
| Parameter | Description |
|---|---|
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.
fn quat_mul_w(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): intParameters
| Parameter | Description |
|---|---|
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).
fn quat_conj_x(qx: int, qy: int, qz: int, qw: int): intParameters
| Parameter | Description |
|---|---|
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).
fn quat_conj_y(qx: int, qy: int, qz: int, qw: int): intParameters
| Parameter | Description |
|---|---|
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).
fn quat_conj_z(qx: int, qy: int, qz: int, qw: int): intParameters
| Parameter | Description |
|---|---|
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).
fn quat_conj_w(qx: int, qy: int, qz: int, qw: int): intParameters
| Parameter | Description |
|---|---|
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.
fn quat_mag_sq(qx: int, qy: int, qz: int, qw: int): intParameters
| Parameter | Description |
|---|---|
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.
fn quat_dot(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int): intParameters
| Parameter | Description |
|---|---|
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).
fn quat_slerp_x(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int, t: int): intParameters
| Parameter | Description |
|---|---|
ax | @param ay @param az @param aw Start quaternion ×10000 |
bx | @param by @param bz @param bw End quaternion ×10000 |
t | Interpolation factor ×1000 (0 = a, 1000 = b) |
Returns: X component of interpolated quaternion ×10000
Example
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.
fn quat_slerp_y(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int, t: int): intParameters
| Parameter | Description |
|---|---|
ax | @param ay @param az @param aw Start quaternion ×10000 |
bx | @param by @param bz @param bw End quaternion ×10000 |
t | Interpolation 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.
fn quat_slerp_z(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int, t: int): intParameters
| Parameter | Description |
|---|---|
ax | @param ay @param az @param aw Start quaternion ×10000 |
bx | @param by @param bz @param bw End quaternion ×10000 |
t | Interpolation 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.
fn quat_slerp_w(ax: int, ay: int, az: int, aw: int, bx: int, by: int, bz: int, bw: int, t: int): intParameters
| Parameter | Description |
|---|---|
ax | @param ay @param az @param aw Start quaternion ×10000 |
bx | @param by @param bz @param bw End quaternion ×10000 |
t | Interpolation 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).
fn quat_euler_x(yaw: int, pitch: int, roll: int): intParameters
| Parameter | Description |
|---|---|
yaw | Y-axis rotation in degrees |
pitch | X-axis rotation in degrees |
roll | Z-axis rotation in degrees |
Returns: X component ×10000
Example
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).
fn quat_euler_y(yaw: int, pitch: int, roll: int): intParameters
| Parameter | Description |
|---|---|
yaw | Y-axis rotation in degrees |
pitch | X-axis rotation in degrees |
roll | Z-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).
fn quat_euler_z(yaw: int, pitch: int, roll: int): intParameters
| Parameter | Description |
|---|---|
yaw | Y-axis rotation in degrees |
pitch | X-axis rotation in degrees |
roll | Z-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).
fn quat_euler_w(yaw: int, pitch: int, roll: int): intParameters
| Parameter | Description |
|---|---|
yaw | Y-axis rotation in degrees |
pitch | X-axis rotation in degrees |
roll | Z-axis rotation in degrees |
Returns: W component ×10000