-
-
Notifications
You must be signed in to change notification settings - Fork 3
Library: Math: Quat
Quaternions are simplified representation of complex numbers on 4 dimensions (1 real & 3 imaginary dimensions). Quats widely known for representing rotations precisely have special desirable properties compared to other form of representation such as 'Euler', 'Matrix' where you would end up with bottleneck due to Gimbal locks. Beside rotations quats are also pretty useful for generic math.
If you still have no idea how useful they are or where to apply/utilize them in the right way, then make sure to read: https://math.dartmouth.edu/~jvoight/quat-book.pdf
It's already imported by default whenever you import assetify. You need to declare the below globally only once:
loadstring(exports.assetify_library:import())()local cQuat1, cQuat2 = math.quat(1, 1, 1, 1), math.quat(2, 2, 2, 2)
local resultant = cQuat1 + cQuat2local cQuat1, cQuat2 = math.quat(1, 1, 1, 1), math.quat(2, 2, 2, 2)
local resultant = cQuat1 - cQuat2--Note: Quaternion multiplications aren't commutative!
local cQuat1, cQuat2 = math.quat(1, 1, 1, 1), math.quat(2, 2, 2, 2)
local resultant = cQuat1 * cQuat2local cQuat1, cQuat2 = math.quat(1, 1, 1, 1), math.quat(2, 2, 2, 2)
local resultant = cQuat1 / cQuat2-
✨ Retrieve's instance's type.
local string: type = self:getType()
-
✨ Creates a quaternion instance.
local quat: cQuat = math.quat( float: x, float: y, float: z, float: w )
-
✨ Destroys an existing quat.
local bool: result = self:destroy()
-
✨ Scales quat w/ specified scale.
local quat: self = self:scale( float: scale )
-
✨ Sets quat's axis angles.
local quat: self = self:setAxisAngle( float: x, float: y, float: z, float: angle )
-
✨ Creates a quat w/ specified axis angles.
local quat: cQuat = math.quat:fromAxisAngle( float: x, float: y, float: z, float: angle )
-
✨ Retrieves euler angles from quat.
local float: x, float: y, float: z = self:toEuler()
-
✨ Creates a quat w/ specified euler angles.
local quat: cQuat = math.quat:fromEuler( float: x, float: y, float: z )