Fandom

CraftStudio Wiki

Scripting Reference/Quaternion

< Scripting Reference

56pages on
this wiki
Add New Page
Comments0 Share

Quaternion:NewEdit

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

Creates a new quaternion

Quaternion:IdentityEdit

[Quaternion] Quaternion:Identity()

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

Quaternion:FromAxisAngleEdit

[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:SqrLengthEdit

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

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

Quaternion * QuaternionEdit

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.SlerpEdit

​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 orientationsEdit

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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.