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

stingray.Matrix4x4 object reference

Description

Represents a 4x4 matrix that stores both the position and the orientation of an object.

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

Functions

Parameters

m :

stingray.Matrix4x4

The matrix whose axis will be returned.

i :

integer

The index of the axis to retrieve. Use 1 to get the X axis, 2 for the Y axis, or 3 for the Z axis.

Returns

stingray.Vector3

The axis at the specified index.

Parameters

m :

stingray.Matrix4x4

The matrix to copy.

Returns

stingray.Matrix4x4

The newly created matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose element will be returned.

i :

integer

The row index. Use 1 to access the local X axis rotation, 2 for the local Y axis rotation, 3 for the local Z axis rotation, or 4 for the translation.

j :

integer

The column index. Use 1 to access the global X component, 2 for the global Y component, 3 for the global Z component, or 4 for the translation.

Returns

number

The value of the element with the specified indices.

Indices are 1-based, so for example, element(1,2) returns the Y-component (2) of the X-axis (1) stored in the matrix.

Parameters

m1 :

stingray.Matrix4x4

The first matrix.

m2 :

stingray.Matrix4x4

The second matrix.

Returns

boolean

Returns true if the two matrices are identical, or false otherwise.

Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be returned.

Returns

stingray.Vector3

The forward axis of the matrix.

Parameters

x :

stingray.Vector3

The orientation of the local X axis.

y :

stingray.Vector3

The orientation of the local Y axis.

z :

stingray.Vector3

The orientation of the local Z axis.

t :

stingray.Vector3

The translation that will be stored in the new matrix.

Returns

stingray.Matrix4x4

The newly created matrix.

Parameters

xx :

number

The magnitude of the local X axis along the global X axis.

xy :

number

The magnitude of the local X axis along the global Y axis.

xz :

number

The magnitude of the local X axis along the global Z axis.

yx :

number

The magnitude of the local Y axis along the global X axis.

yy :

number

The magnitude of the local Y axis along the global Y axis.

yz :

number

The magnitude of the local Y axis along the global Z axis.

zx :

number

The magnitude of the local Z axis along the global X axis.

zy :

number

The magnitude of the local Z axis along the global Y axis.

zz :

number

The magnitude of the local Z axis along the global Z axis.

tx :

number

The translation along the global X axis.

ty :

number

The translation along the global Y axis.

tz :

number

The translation along the global Z axis.

Returns

stingray.Matrix4x4

The newly created matrix.

Equivalent to Matrix4x4().

Parameters

q :

stingray.Quaternion

The rotation that will be stored in the new matrix.

Returns

stingray.Matrix4x4

The newly created matrix.

Parameters

q :

stingray.Quaternion

The rotation that will be stored in the new matrix.

t :

stingray.Vector3

The translation that will be stored in the new matrix.

Returns

stingray.Matrix4x4

The newly created matrix.

Parameters

t :

stingray.Vector3

The translation that will be stored in the new matrix.

Returns

stingray.Matrix4x4

The newly created matrix.

Parameters

m :

stingray.Matrix4x4

The matrix to invert.

Returns

stingray.Matrix4x4

The inverted matrix.

Parameters

m :

stingray.Matrix4x4

The matrix to validate.

Returns

boolean

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

Parameters

m :

stingray.Matrix4x4

The matrix to validate.

Returns

boolean

Returns true if this matrix can be applied to a physics object, or false otherwise.

For example, a matrix may be unfit for use with physics objects if it contains shearing (non-orthogonal axes) or other unexpected geometry.

Parameters

m1 :

stingray.Matrix4x4

The first matrix.

m2 :

stingray.Matrix4x4

The second matrix.

t :

number

The ratio, or interpolation point, between the two matrices. May be any value between 0 and 1 inclusive. Values closer to 0 produce matrices closer to m1; values closer to 1 produce matrices closer to m2.

Returns

stingray.Matrix4x4

The resulting matrix.

This is done by lerping the translation and rotation separately. Scale, etc., are not lerped.

Parameters

m1 :

stingray.Matrix4x4

The first matrix to multiply.

m2 :

stingray.Matrix4x4

The second matrix to multiply.

Returns

stingray.Matrix4x4

The product of the multiplication.

This will create the composite transform of the individual matrix transforms.

Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be returned.

Returns

stingray.Vector3

The right axis of the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose rotation will be returned.

Returns

stingray.Quaternion

The rotation of the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose scale will be returned.

Returns

stingray.Vector3

The scale of the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose axis will be set.

i :

integer

The index of the axis to set. Use 1 to get the X axis, 2 for the Y axis, or 3 for the Z axis.

v :

stingray.Vector3

The axis value to set.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose element will be set.

i :

integer

The row index. Use 1 to set the local X axis rotation, 2 for the local Y axis rotation, 3 for the local Z axis rotation, or 4 for the translation.

j :

integer

The column index. Use 1 to set the global X component, 2 for the global Y component, 3 for the global Z component, or 4 for the translation.

value :

number

The value to set for the element with the specified indices.

Returns
This function does not return any values.

Indices are 1-based, so for example, set_element(1,2) sets the Y-component (2) of the X-axis (1) stored in the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be set.

forward :

stingray.Vector3

The new forward axis of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be set.

right :

stingray.Vector3

The new right axis of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose rotation will be set.

r :

stingray.Quaternion

The new rotation of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose scale will be set.

s :

stingray.Vector3

The new scale of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose translation will be set.

t :

stingray.Vector3

The new translation of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be set.

up :

stingray.Vector3

The new up axis of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be set.

x :

stingray.Vector3

The new X axis of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be set.

y :

stingray.Vector3

The new Y axis of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be set.

z :

stingray.Vector3

The new Z axis of the matrix.

Returns
This function does not return any values.
Parameters

m :

stingray.Matrix4x4

The matrix to break down into its elements.

Returns

number

The magnitude of the local X axis along the global X axis.

number

The magnitude of the local X axis along the global Y axis.

number

The magnitude of the local X axis along the global Z axis.

number

The magnitude of the local Y axis along the global X axis.

number

The magnitude of the local Y axis along the global Y axis.

number

The magnitude of the local Y axis along the global Z axis.

number

The magnitude of the local Z axis along the global X axis.

number

The magnitude of the local Z axis along the global Y axis.

number

The magnitude of the local Z axis along the global Z axis.

number

The translation along the global X axis.

number

The translation along the global Y axis.

number

The translation along the global Z axis.

Parameters

m :

stingray.Matrix4x4

The matrix to return as a string.

Returns

string

The string representation.

Use this function only for debugging purposes.

Parameters

m :

stingray.Matrix4x4

The matrix to use for the transform.

p :

stingray.Vector3

The position to be transformed.

Returns

stingray.Vector3

The new position, after being transformed by the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix to use for the transform.

v :

stingray.Vector3

The vector to be transformed.

Returns

stingray.Vector3

The new position, after being transformed by the matrix.

This function may be useful when translating directions (rather than positions) between two different coordinate systems.

Parameters

m :

stingray.Matrix4x4

The matrix whose translation will be returned.

Returns

stingray.Vector3

The translation of the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be returned.

Returns

stingray.Vector3

The up axis of the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be returned.

Returns

stingray.Vector3

The X axis of the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be returned.

Returns

stingray.Vector3

The Y axis of the matrix.

Parameters

m :

stingray.Matrix4x4

The matrix whose axis value will be returned.

Returns

stingray.Vector3

The Z axis of the matrix.

Parameters
This function does not accept any parameters.
Returns

stingray.Matrix4x4

The zero matrix.