Quaternion - stingray.Quaternion object reference - Stingray Lua API Reference

stingray.Quaternion object reference

Description

Represents a rotation in the quaternion formulation (x, y, z, w).

Note that it is not strictly necessary to understand quaternions to use these obejcts; you can just treat them as opaque representations of rotations.

NOTE: Quaternion objects are temporary. You can only use them in the frame in which they were generated. If you need to save a Quaternion across multiple frames, use a QuaternionBox instead. For more information, see Object Lifetimes and Userdata Binding.

Functions

Parameters

quat :

stingray.Quaternion

The quaternion whose rotation angle will be returned.

Returns

number

The rotation angle of the quaternion's up vector around the facing direction, expressed in radians.

Parameters

axis :

stingray.Vector3

The main axis for the quaternion.

angle :

number

The angle around the main axis, expressed in radians.

Returns

stingray.Quaternion

The newly created quaternion.

Equivalent to stingray.Quaternion().

Parameters

quat :

stingray.Quaternion

The quaternion whose conjugate will be returned.

Returns

stingray.Quaternion

The conjugate of quat.

Parameters

quat :

stingray.Quaternion

The quaternion to decompose.

Returns

stingray.Vector3

The X, Y and Z values that define the facing direction of the quaternion.

number

The rotation of the quaternion's up vector around the facing direction, expressed in radians.

Parameters

quat_a :

stingray.Quaternion

The first quaternion.

quat_b :

stingray.Quaternion

The second quaternion.

Returns

number

The dot product.

Parameters

quat_a :

stingray.Quaternion

The first quaternion.

quat_b :

stingray.Quaternion

The second quaternion.

Returns

boolean

true if all members of the two quaternions are equal, or false otherwise.

Parameters

quat :

stingray.Quaternion

The quaternion whose axis will be retrieved.

Returns

stingray.Vector3

The forward axis of the quaternion rotation.

Parameters

x :

number

The X element.

y :

number

The Y element.

z :

number

The Z element.

w :

number

The W element.

Returns

stingray.Quaternion

The newly created quaternion.

Parameters

x :

number

The euler X axis rotation, expressed in degrees.

y :

number

The euler Y axis rotation, expressed in degrees.

z :

number

The euler Z axis rotation, expressed in degrees.

Returns

stingray.Quaternion

The newly created quaternion.

Parameters

matrix :

stingray.Matrix4x4

A matrix that contains the rotation you want to extract.

Returns

stingray.Quaternion

The newly created quaternion.

Parameters

quat :

stingray.Quaternion

The quaternion to be inverted.

Returns

stingray.Quaternion

The inverted rotation.

Parameters

quat :

stingray.Quaternion

The quaternion to test.

Returns

boolean

Returns true if all components of the quaternion are valid numbers, or false if any component is #NaN or #INF.

Parameters

quat_a :

stingray.Quaternion

The first quaternion.

quat_b :

stingray.Quaternion

The second quaternion.

t :

number

The ratio, or interpolation point, between the two quaternions. May be any value between 0 and 1 inclusive. Values closer to 0 produce rotations closer to quat_a; values closer to 1 produce rotations closer to quat_b.

Returns

stingray.Quaternion

The resulting Quaternion.

The lerp performed by this function is a normalized lerp, or nlerp, which usually gives the best result.

Parameters

dir :

stingray.Vector3

The forward direction for the quaternion.

up :

stingray.Vector3?

Optional; specifies the up vector for the new quaternion. If omitted, the positive direction of the Z axis is used: (0,0,1).

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns

stingray.Quaternion

The newly created quaternion.

Parameters

quat :

stingray.Quaternion

The quaternion to convert.

Returns

stingray.Matrix4x4

A Matrix4x4 that expresses the same rotation as the quaternion.

Parameters

quat_a :

stingray.Quaternion

The first quaternion.

quat_b :

stingray.Quaternion

The second quaternion.

Returns

stingray.Quaternion

The product of the multiplication.

This creates the rotation you would get by first rotating the object by quat_b, then rotating it by quat_a.

Parameters

quat :

stingray.Quaternion

The quaternion whose length will be returned.

Returns

number

The length of the quaternion.

Parameters

quat :

stingray.Quaternion

The quaternion to be normalized.

Returns

stingray.Quaternion

The normalized rotation.

Parameters

quat :

stingray.Quaternion

The quaternion whose axis will be retrieved.

Returns

stingray.Vector3

The right axis of the quaternion rotation.

Parameters

quat :

stingray.Quaternion

The quaternion that will be used to rotate the vector.

vector :

stingray.Vector3

The vector to be rotated.

Returns

stingray.Vector3

The vector after rotation.

Parameters

quat :

stingray.Quaternion

The quaternion to set up.

x :

number

The new X component value for the quaternion's main axis.

y :

number

The new Y component value for the quaternion's main axis.

z :

number

The new Z component value for the quaternion's main axis.

w :

number

The new W component value, defining the rotation of the up vector around the quaternion's main axis.

Returns

stingray.Quaternion

The resulting quaternion.

Parameters

quat :

stingray.Quaternion

The quaternion to decompose into its elements.

Returns

number

The X component value of the quaternion's axis.

number

The Y component value of the quaternion's axis.

number

The Z component value of the quaternion's axis.

number

The W component value: the rotation of the local up vector around the quaternion's axis.

Parameters

quat :

stingray.Quaternion

The quaternion to convert.

Returns

number

The euler X axis rotation, expressed in degrees.

number

The euler Y axis rotation, expressed in degrees.

number

The euler Z axis rotation, expressed in degrees.

Parameters

quat :

stingray.Quaternion

The quaternion to return as a string.

Returns

string

The string representation.

Use this function only for debugging purposes.

Parameters

quat :

stingray.Quaternion

The quaternion whose axis will be retrieved.

Returns

stingray.Vector3

The up axis of the quaternion rotation.