CraftStudio Wiki
Register
Advertisement

Quaternion:New[]

[Quaternion] Quaternion:New( [number] x, [number] y, [number] z, [number] w )

Creates a new quaternion

Quaternion:Identity[]

[Quaternion] Quaternion:Identity()

Returns an identity quaternion (x=0, y=0, z=0, w=1)

Quaternion:FromAxisAngle[]

[Quaternion] Quaternion:FromAxisAngle( [Vector3] axis, [number] angle )

Returns a quaternion which rotates by the specified angle (in degrees) around the specified axis.

Quaternion:Length, Quaternion:SqrLength[]

[number] Quaternion:Length()
[number] Quaternion:SqrLength()

Returns the magnitude (or the square of the magnitude) of the specified quaternion

Quaternion * Quaternion[]

Returns a new quaternion, result of the composition of the two specified quaternions

Note that order matters, A * B isn't equivalent to B * A for quaternions.

Quaternion.Slerp[]

​Quaternion.Slerp( [Quaternion] a, [Quaternion] b, [number] amount )

Do a (spherical) linear interpolation between orientation a and orientation b, by the specified amount (between 0 and 1).

Example: Get the orientation half-way between two orientations[]

 local a = Quaternion:FromAxisAngle( Vector3:Up(), 45 )
 local b = Quaternion:FromAxisAngle( Vector3:Left(), 20 )
 
 local halfwayOrientation = Quaternion.Slerp( a, b, 0.5 )
Advertisement