Quat

Associated namespace: sm.quat

A userdata object representing a quaternion.

Values:

Functions:

Operations:

OperationReturn typeDescription
Quat == QuatbooleanChecks if two quaternions are equal.
Quat * QuatQuatReturns the Hamilton product of two quaternions.
Quat * Vec3Vec3Returns the rotation by a quaternion on a vector.

w number

Get:

Returns the W value of a quaternion.

Set:

Sets the W value of a quaternion.


x number

Get:

Returns the X value of a quaternion.

Set:

Sets the X value of a quaternion.


y number

Get:

Returns the Y value of a quaternion.

Set:

Sets the Y value of a quaternion.


z number

Get:

Returns the Z value of a quaternion.

Set:

Sets the Z value of a quaternion.


getAt(quaternion)

Returns the quaternions at vector.

Parameters:

TypeNameDescription
QuatquaternionThe quaternion.

Returns:

TypeDescription
Vec3The at vector.

getRight(quaternion)

Returns the quaternions right vector.

Parameters:

TypeNameDescription
QuatquaternionThe quaternion.

Returns:

TypeDescription
Vec3The right vector.

getUp(quaternion)

Returns the quaternions up vector.

Parameters:

TypeNameDescription
QuatquaternionThe quaternion.

Returns:

TypeDescription
Vec3The up vector.

inverse(quaternion)

Inverts the quaternion.

Parameters:

TypeNameDescription
QuatquaternionThe quaternion.

Returns:

TypeDescription
QuatThe inverted quaternion.

normalize(quaternion)

Normalizes a quaternion, ie. converts to a unit quaternion of length 1.

Parameters:

TypeNameDescription
QuatquaternionThe quaternion.

Returns:

TypeDescription
QuatThe normalized quaternion.

round90(quaternion)

Rounds the quaternion rotation into 90 degree steps

Parameters:

TypeNameDescription
QuatquaternionThe quaternion.

Returns:

TypeDescription
QuatThe rounded quaternion.

safeNormalize(quaternion, fallback)

Normalizes a quaternion with safety, ie. converts to a unit quaternion of length 1.

Parameters:

TypeNameDescription
QuatquaternionThe quaternion.
QuatfallbackThe fallback quaternion

Returns:

TypeDescription
QuatThe normalized quaternion.