# Class: matrix4x4

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

## Hierarchy

    o-+ mathlib
      o-+ matrix4x4

## Methods:

### Method overview:

- affineinvert
- column
- component
- compressed3x3
- compressed4x3
- copy
- identity
- invert
- lookat
- mul
- mulfull
- new
- pos
- projmatrix
- rotaxis
- rotdeg
- rotquat
- rotrad
- row
- scale
- setaxisangle
- tostring
- transform
- transformrotate
- transpose
- viewmatrix

new ([table float16]/[matrix4x4])
  returns: (matrix4x4 m)
  constructs identity matrix or uses lua table or other matrix4x4 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 (matrix4x4 m,[matrix4x4 inv])
  returns: (matrix4x4 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 (matrix4x4 m,int column,[float x,y,z,w])
  returns: ([float x,y,z,w])
  sets/gets column (0-3) vector.
component (matrix4x4,int index [0..15],[float])
  returns: ([float])
  returns or sets single matrix entry.
compressed3x3 (matrix4x4)
  returns: (matrix4x4)
  copies and compresses the storage and returns new, for shadercgparamhost:value useage.
compressed4x3 (matrix4x4)
  returns: (matrix4x4)
  copies and compresses the storage and returns new, for shadercgparamhost:value useage.
copy (matrix4x4 to,matrix4x4 from)
  returns: (matrix4x4 to)
  copys from other to itself
identity (matrix4x4)
  returns: (matrix4x4)
  sets diagonal of matrix to 1, rest to 0
invert (matrix4x4 m,[matrix4x4 inv])
  returns: (matrix4x4 m)
  inverts m, or m = invert of inv
lookat (matrix4x4 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 (matrix4x4 a, b ,[c])
  returns: (matrix4x4 a)
  multiplys: a = b*c or a = a*b. faster but sets W coordinate of each colum to 0, cept last to 1
mulfull (matrix4x4 a, b ,[c])
  returns: (matrix4x4 a)
  multiplys: a = b*c or a = a*b. accurately takes all 16 values into account.
pos (matrix4x4 m,[float x,y,z])
  returns: ([float x,y,z])
  sets/gets position of matrix
projmatrix (matrix4x4, nearplane, farplane, fov, aspect)
  returns: (matrix4x4)
  turns self into a projection matrix usable for cameras and projectors. negative fov means 'size' for orthographic projection. aspect is width/height.
rotaxis (matrix4x4 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 (matrix4x4 m,[float x,y,z])
  returns: ([float x,y,z])
  returns or sets rotation in degrees
rotquat (matrix4x4 m,[float x,y,z,w])
  returns: ([float x,y,z,w])
  sets/gets rotation as quaternion
rotrad (matrix4x4 m,[float x,y,z])
  returns: ([float x,y,z])
  returns or sets rotation in radians
row (matrix4x4 m,int column,[float x,y,z,w])
  returns: ([float x,y,z,w])
  sets/gets row (0-3) vector.
scale (matrix4x4 m,[float x,y,z])
  returns: ([float x,y,z])
  sets/gets scale factors of matrix
setaxisangle (matrix4x4 a, float axisX,axisY,axisZ ,rotation)
  returns: ()
  sets rotation around angle
tostring (matrix4x4 vec)
  returns: (string str)
  returns matrix as string
transform (matrix4x4 m,float x,y,z)
  returns: (float x,y,z)
  transforms the three given coordinates
transformrotate (matrix4x4 m,float x,y,z)
  returns: (float x,y,z)
  rotate the three given coordinates
transpose (matrix4x4 m,[matrix4x4 inv])
  returns: (matrix4x4 m)
  transposes m, or m = transpose of inv
viewmatrix (matrix4x4)
  returns: (matrix4x4)
  turns self into a viewmatrix usable for cameras

## Inherited Methods:

### From mathlib

quatslerpq, quatslerpqt