matrixΒΆ

class matrix

A 4x4 transformation matrix

Members

Constructors:

matrix result create ( ) Create an unitilialised matrix.
matrix result create ( boolean identity ) Create an identity matrix if identity parameter is true.
matrix result create ( matrix source ) Create a copy of the input matrix
matrix result create ( {number} source ) Create a matrix from an array of 16 numbers
matrix result create ( number m11 , number m12 , number m13 , number m14 , ... ... , number m41 , number m42 , number m43 , number m44 ) Create a matrix from 16 numbers

Methods:

matrix result * ( matrix other ) Returns self*other
matrix result + ( matrix other ) Returns self+other
matrix result - ( matrix other ) Returns self-other
{number} result asarray ( ) Converts the matrix as an array table of 16 numbers
matrix result compose ( matrix other ) Returns the composition of the two matrices
nil copy ( matrix source ) Copy the source matrix into this matrix
number sx,sy,sz,rx,ry,rz,tx,ty,tz decompose ( ) Decompose the matrix into scale, rotation and translation components.
boolean isequal equals ( matrix other ) Compares this matrix to other matrix.
point3 result geti ( ) Return the i direction of the matrix.
matrix result getinverted ( ) Return the inverted matrix.
point3 result getj ( ) Return the j direction of the matrix.
point3 result getk ( ) Return the k direction of the matrix.
point3 result gettranslation ( ) Return the translation of the matrix.
matrix result gettransposed ( ) Return the transposed matrix.
nil lookat ( point3 position , point3 target , point3 up ) Set the matrix to look from position to target with up as roll.
nil normalize ( ) Normalize the line components of the matrix.
nil pivot ( point3 axis , number angle , point3 pivot ) Rotate this matrix around around a pivot, an axis and an angle in radian
nil rotate ( point3 axis , number angle ) Rotate the matrix around an axis with an angle in radian
nil rotatex ( number angle ) Rotate the matrix around the x axis.
nil rotatey ( number angle ) Rotate the matrix around the y axis.
nil rotatez ( number angle ) Rotate the matrix around the z axis.
nil scale ( number scalex , number scaley , number scalez ) Scale the matrix on all axises.
nil serialstring ( ) Returns a Lua evaluable string to create this object
nil seti ( point3 newi ) Set the i direction of the matrix.
nil setidentity ( ) Set the matrix to identity.
nil setj ( point3 newj ) Set the j direction of the matrix.
nil setk ( point3 newk ) Set the k direction of the matrix.
nil settranslation ( point3 newt ) Set the translation of the matrix.
string boots toboots ( ) Returns the boots code for this matrix.
point3 result transform ( point3 p ) Return the transform of the point p by the matrix. (p * self)
nil translate ( point3 translation ) Translate the matrix.
point3 result vtransform ( point3 v ) Return the transform of the vector p by the matrix. (v * self)

Functions:

matrix result createcomposite ( number sx , number sy , number sz , number rx , number ry , number rz , number tx , number ty , number tz ) Create the composite matrix using scale, rotation and translation. The scale factors are first applied, then x rotation, y rotation and z rotation, and the the translation is applied.
matrix result createfromarray ( {number} array ) Create a new matrix object from a array table of numbers
matrix result createidentity ( )
matrix result createlookat ( point3 pos , point3 target , float roll , point3 up , string direction ) Compute a lookat matrix. pos and target must be specified. rool OR up can be specified.
matrix result fromarray ( {number} array ) Create a new matrix object from a array table of numbers

Documentation

matrix result * ( matrix other )

Returns self*other

Arguments:

  • other

Return:

  • result


matrix result + ( matrix other )

Returns self+other

Arguments:

  • other

Return:

  • result


matrix result - ( matrix other )

Returns self-other

Arguments:

  • other

Return:

  • result


{number} result asarray ( )

Converts the matrix as an array table of 16 numbers

Return:

  • result The corresponding array of numbers


matrix result compose ( matrix other )

Returns the composition of the two matrices

self will be applied first, then other.
Arguments:

  • other

Return:

  • result


nil copy ( matrix source )

Copy the source matrix into this matrix

Arguments:

  • source The matrix to copy


number sx,sy,sz,rx,ry,rz,tx,ty,tz decompose ( )

Decompose the matrix into scale, rotation and translation components.

Return:

  • sx,sy,sz,rx,ry,rz,tx,ty,tz The decomposed matrix components


boolean isequal equals ( matrix other )

Compares this matrix to other matrix.

Arguments:

  • other

Return:

  • isequal True if all values of the matrices are equal


point3 result geti ( )

Return the i direction of the matrix.

Return:

  • result


matrix result getinverted ( )

Return the inverted matrix.

Return:

  • result


point3 result getj ( )

Return the j direction of the matrix.

Return:

  • result


point3 result getk ( )

Return the k direction of the matrix.

Return:

  • result


point3 result gettranslation ( )

Return the translation of the matrix.

Return:

  • result


matrix result gettransposed ( )

Return the transposed matrix.

Return:

  • result


nil lookat ( point3 position , point3 target , point3 up )

Set the matrix to look from position to target with up as roll.

Arguments:

  • position The viewing position
  • target The target position
  • up The up vectory


nil normalize ( )

Normalize the line components of the matrix.


nil pivot ( point3 axis , number angle , point3 pivot )

Rotate this matrix around around a pivot, an axis and an angle in radian

Arguments:

  • axis The rotation axis
  • angle The rotation angle in radian
  • pivot The rotation pivot


nil rotate ( point3 axis , number angle )

Rotate the matrix around an axis with an angle in radian

Arguments:

  • axis The rotation axis
  • angle The rotation angle


nil rotatex ( number angle )

Rotate the matrix around the x axis.

Arguments:

  • angle The rotation angle in radians


nil rotatey ( number angle )

Rotate the matrix around the y axis.

Arguments:

  • angle The rotation angle in radians


nil rotatez ( number angle )

Rotate the matrix around the z axis.

Arguments:

  • angle The rotation angle in radians


nil scale ( number scalex , number scaley , number scalez )

Scale the matrix on all axises.

Arguments:

  • scalex The scale factor on x axis
  • scaley The scale factor on y axis
  • scalez The scale factor on z axis


nil serialstring ( )

Returns a Lua evaluable string to create this object


nil seti ( point3 newi )

Set the i direction of the matrix.

Arguments:

  • newi


nil setidentity ( )

Set the matrix to identity.


nil setj ( point3 newj )

Set the j direction of the matrix.

Arguments:

  • newj


nil setk ( point3 newk )

Set the k direction of the matrix.

Arguments:

  • newk


nil settranslation ( point3 newt )

Set the translation of the matrix.

Arguments:

  • newt


string boots toboots ( )

Returns the boots code for this matrix.

Return:

  • boots


point3 result transform ( point3 p )

Return the transform of the point p by the matrix. (p * self)

Arguments:

  • p

Return:

  • result


nil translate ( point3 translation )

Translate the matrix.

Arguments:

  • translation The translation vector


point3 result vtransform ( point3 v )

Return the transform of the vector p by the matrix. (v * self)

Arguments:

  • v

Return:

  • result


matrix result createcomposite ( number sx , number sy , number sz , number rx , number ry , number rz , number tx , number ty , number tz )

Create the composite matrix using scale, rotation and translation. The scale factors are first applied, then x rotation, y rotation and z rotation, and the the translation is applied.

Arguments:

  • sx The x scale
  • sy The y scale
  • sz The z scale
  • rx The x rotation angle in radian
  • ry The y rotation angle in radian
  • rz The z rotation angle in radian
  • tx The x translation
  • ty The y translation
  • tz The z translation

Return:

  • result


matrix result createfromarray ( {number} array )

Create a new matrix object from a array table of numbers

Arguments:

  • array The source array table of numbers

Return:

  • result The new matrix object


matrix result createidentity ( )

Return:

  • result A new matrix set to identity


matrix result createlookat ( point3 pos , point3 target , float roll , point3 up , string direction )

Compute a lookat matrix. pos and target must be specified. rool OR up can be specified.

Arguments:

  • pos The position
  • target The position to aim
  • roll The roll angle in radian or nil
  • up The up vector or nil
  • direction The lookup direction. Can be nil, "z" or "-z". Default is "z".

Return:

  • result The lookup matrix


matrix result fromarray ( {number} array )

Create a new matrix object from a array table of numbers

Arguments:

  • array The source array table of numbers

Return:

  • result The new matrix object