Quaternion Library
Implements quaternions.
quaternion
Quaternion library for Luanti.
Quaternions are 4D complex numbers used for 3D rotations.
Reference
quaternion.metatable is the metatable used when creating quaternions.
The following functions create new quaternions.
quaternion.compose(w,x,y,z) returns a quaternion with the respective components.
quaternion.copy(q) returns a copy of the same quaternion.
quaternion.realimag(w,xyz) returns a quaternion created with a number and a vector.
quaternion.identity() returns the identity quaternion.
quaternion.new(...) automatically selects from the above constructors depending on argument count.
quaternion.scale(q, n) returns a componentwise scaled quaternion.
quaternion.qmultiply(q1, q2) returns the quaternion multiplication of q1 and q2.
quaternion.multiply(a, b) automatically selects from the above multiplication functions depending on type. Used for overloading a * b.
quaternion.norminvert(q) returns the inverse of a quaternion. Argument must be normalized.
quaternion.fromto(v1, v2) returns the shortest quaternion that rotates vectors v1 to v2.
quaternion.quickfromto(n1, n2) is the above but its arguments must be normalized.
quaternion.axisangle(axis, angle) returns a quaternion which represents a righthanded rotation around axis by angle radians.
The following functions create new vectors.
vector.perpendicular(v) returns an arbitrary perpendicular vector.
vector.rotatequat(v, q) returns a rotation of the vector v by the quaternion q.
Links
- Source: https://codeberg.org/The4codeblocks/luanti_quaternions.git
- Original ContentDB page: content.luanti.org/packages/The4spaceconstants/quaternion/
License
0BSD
Development state
BETA
| Version | Date | Min engine | Size | Download |
|---|---|---|---|---|
| 1.1.0.0 | 2026-08-01 18:09:58 | 73.2 KB | Download |