Module mat4
mat4: A 4x4 matrix
Functions
mat4:index (column, row) | Get the array index in a matrix: |
mat4:getcell (column, row) | Get the value of a matrix cell |
mat4:setcell (column, row, value) | Set the value of a matrix cell |
mat4:row (i) | Get a row of the matrix as a vec4 |
mat4:col (i) | Get a column of the matrix as a vec4 |
mat4:row3 (i) | Get a row of the matrix as a vec3 |
mat4:col3 (i) | Get a column of the matrix as a vec3 |
mat4:copy () | Create a copy of the matrix |
mat4:transposenew () | Get transposed copy of the matrix |
mat4:set (...) | Set the values of a matrix from a list of arguments |
mat4:identity () | Set or create identity matrix If called without object (mat4.identity()), returns a new matrix If called with object (mat4:identity()), resets the matrix to identity |
mat4:transform (v) | Computes product of matrix multiplied by column vector, r = m * vCol This is typically what is required to project a vertex through a transform For a better explanation, @see http:--xkcd.com/184/ |
mat4:transform_transposed (v) | Computes product of a vec4 with the transpose of the matrix |
fromPositionAxis (pos, ux, uy, uz) | Generate a matrix from a position and three unit axes |
perspectivePlane (nearBL, nearBR, nearTL, eye, near, far) | Calculate perspective projection for near plane and eye coordinates (nearBL, nearBR, nearTL, eye) all share the same coordinate system (nearBR,nearBL) and (nearTL,nearBL) should form a right angle (eye) can be set freely, allowing diverse off-axis projections See Generalized Perspective Projection, Robert Kooima, 2009, EVL |
perspectiveOffAxis (fovy, aspect, near, far, xshift, yshift, focal) | Generalized off-axis perspective: |
Functions
- mat4:index (column, row)
-
Get the array index in a matrix:
Parameters:
- column (zero-based)
- row (zero-based)
Returns:
-
index
- mat4:getcell (column, row)
-
Get the value of a matrix cell
Parameters:
- column (zero-based)
- row (zero-based)
Returns:
-
value
- mat4:setcell (column, row, value)
-
Set the value of a matrix cell
Parameters:
- column (zero-based)
- row (zero-based)
- value (optional, default 0)
Returns:
-
self
- mat4:row (i)
-
Get a row of the matrix as a vec4
Parameters:
- i (zero-based)
Returns:
-
vec4
- mat4:col (i)
-
Get a column of the matrix as a vec4
Parameters:
- i (zero-based)
Returns:
-
vec4
- mat4:row3 (i)
-
Get a row of the matrix as a vec3
Parameters:
- i (zero-based)
Returns:
-
vec3
- mat4:col3 (i)
-
Get a column of the matrix as a vec3
Parameters:
- i (zero-based)
Returns:
-
vec3
- mat4:copy ()
-
Create a copy of the matrix
Returns:
-
new matrix
- mat4:transposenew ()
-
Get transposed copy of the matrix
Returns:
-
new matrix
- mat4:set (...)
-
Set the values of a matrix from a list of arguments
Parameters:
- ... arguments to set
Returns:
-
self
- mat4:identity ()
-
Set or create identity matrix
If called without object (mat4.identity()), returns a new matrix
If called with object (mat4:identity()), resets the matrix to identity
Returns:
-
matrix
- mat4:transform (v)
-
Computes product of matrix multiplied by column vector, r = m * vCol
This is typically what is required to project a vertex through a transform
For a better explanation, @see http:--xkcd.com/184/
Parameters:
- v vec4 column vector to multiply
Returns:
-
vec4 result
- mat4:transform_transposed (v)
-
Computes product of a vec4 with the transpose of the matrix
Parameters:
- v vec4 vector to multiply
Returns:
-
vec4
- fromPositionAxis (pos, ux, uy, uz)
-
Generate a matrix from a position and three unit axes
Parameters:
- pos vec3 position
- ux vec3 right-vector (unit length)
- uy vec3 up-vector (unit length)
- uz vec3 rear-vector (unit length)
Returns:
-
matrix
- perspectivePlane (nearBL, nearBR, nearTL, eye, near, far)
-
Calculate perspective projection for near plane and eye coordinates
(nearBL, nearBR, nearTL, eye) all share the same coordinate system
(nearBR,nearBL) and (nearTL,nearBL) should form a right angle
(eye) can be set freely, allowing diverse off-axis projections
See Generalized Perspective Projection, Robert Kooima, 2009, EVL
Parameters:
- nearBL bottom-left near-plane coordinate (world-space)
- nearBR bottom-right near-plane coordinate (world-space)
- nearTL top-left near-plane coordinate (world-space)
- eye eye coordinate (world-space)
- near near plane distance from eye
- far far plane distance from eye
- perspectiveOffAxis (fovy, aspect, near, far, xshift, yshift, focal)
-
Generalized off-axis perspective:
Parameters:
- fovy
- aspect
- near
- far
- xshift
- yshift
- focal