Class: matrix16

4x4 matrices are used for position and rotational transformations. They are saved column-major.

Hierarchy

o-+ mathlib
  o-+ matrix16

Methods:

Method overview:


new ([table float16])
returns: (matrix16 m)
constructs identity matrix or uses lua table to fill values. If a table with 16 elements is passed, the values are interpreted as a matrix and will The OpenGL matrixstyle (column-major) is used so the x,y,z translation is found at element index 12,13,14 (or 13,14,15 as lua arrays start at index 1, while C arrays start at index 0)
affineinvert (matrix16 m,[matrix16 inv])
returns: (matrix16 m)
inverts m, or m = invert of inv. Affine invert is faster and more robust than regular invert, but will only work on non-scaled orthogonal matrices.
column (matrix16 m,int column,[float x,y,z,w])
returns: ([float x,y,z,w])
sets/gets column (0-3) vector.
component (matrix16,int index [0..15],[float])
returns: ([float])
returns or sets single matrix entry.
copy (matrix16 to,matrix16 from)
returns: (matrix16 to)
copys from other to itself
identity (matrix16)
returns: (matrix16)
sets diagonal of matrix to 1, rest to 0
invert (matrix16 m,[matrix16 inv])
returns: (matrix16 m)
inverts m, or m = invert of inv
lookat (matrix16 a, float toX,toY,toZ, upX,upY,upZ, [int axis 0..2])
returns: ()
sets rotation axis, so that axis (0:x 1:y 2:z default is y) aims at given target pos from current matrix position.
mul (matrix16 a, b ,[c])
returns: (matrix16 a)
multiplys: a = b*c or a = a*b. faster but sets W coordinate of each colum to 0, cept last to 1
mulfull (matrix16 a, b ,[c])
returns: (matrix16 a)
multiplys: a = b*c or a = a*b. accurately takes all 16 values into account.
pos (matrix16 m,[float x,y,z])
returns: ([float x,y,z])
sets/gets position of matrix
rotaxis (matrix16 m,[float Xx,Xy,Xz, Yx,Yy,Yz, Zx,Zy,Zz])
returns: ([float Xx,Xy,Xz, Yx,Yy,Yz, Zx,Zy,Zz])
returns or sets rotation axis, make sure they make a orthogonal basis.
rotdeg (matrix16 m,[float x,y,z])
returns: ([float x,y,z])
returns or sets rotation in degrees
rotquat (matrix16 m,[float x,y,z,w])
returns: ([float x,y,z,w])
sets/gets rotation as quaternion
rotrad (matrix16 m,[float x,y,z])
returns: ([float x,y,z])
returns or sets rotation in radians
scale (matrix16 m,[float x,y,z])
returns: ([float x,y,z])
sets/gets scale factors of matrix
setaxisangle (matrix16 a, float axisX,axisY,axisZ ,rotation)
returns: ()
sets rotation around angle
tostring (matrix16 vec)
returns: (string str)
returns matrix as string
transform (matrix16 m,float x,y,z)
returns: (float x,y,z)
transforms the three given coordinates
transformrotate (matrix16 m,float x,y,z)
returns: (float x,y,z)
rotate the three given coordinates
transpose (matrix16 m,[matrix16 inv])
returns: (matrix16 m)
transposes m, or m = transpose of inv

Inherited Methods:

From mathlib

quatslerpq, quatslerpqt