Quat
Associated namespace: sm.quat
A userdata object representing a quaternion.
Values:-
x
[ number ]Get
: The quat's X value.Set
: Sets the quat's X value.
-
y
[ number ]Get
: The quat's Y value.Set
: Sets the quat's Y value.
-
z
[ number ]Get
: The quat's Z value.Set
: Sets the quat's Z value.
-
w
[ number ]Get
: The quat's W value.Set
: Sets the quat's W value.
Operation | Description |
---|---|
Quat == Quat | Checks if two quaternions are equal. |
Quat * Quat | Returns the Hamilton product of two quaternions. |
Quat * Vec3 | Returns the rotation by a quaternion on a vector. |
note
This information might be useful when multiplying a quaternion with another.
The wikipedia page linked above uses the w, xi, yj, zk
representation, while the game uses xi, yj, zk, w
.
Quat1 * Quat2
is equal to:
sm.quat.new(
Quat1.w * Quat2.x + Quat1.x * Quat2.w + Quat1.y * Quat2.z - Quat1.z * Quat2.y,
Quat1.w * Quat2.y - Quat1.x * Quat2.z + Quat1.y * Quat2.w + Quat1.z * Quat2.x,
Quat1.w * Quat2.z + Quat1.x * Quat2.y - Quat1.y * Quat2.x + Quat1.z * Quat2.w,
Quat1.w * Quat2.w - Quat1.x * Quat2.x - Quat1.y * Quat2.y - Quat1.z * Quat2.z
)
Also, (Quat1 * Quat2) * Vec3
is equal to Quat1 * (Quat2 * Vec3)