mat4 cubeTransform
(int face)
Returns cube viewing matrix for the given cube face.
Arguments
- int face - Cube face number.
Return value
Cube viewing matrix.
mat4 frustum
(float left, float right, float bottom, float top, float znear, float zfar)
Returns perspective projection matrix:
2.0 * znear / (right - left) | 0.0 | (right + left) / (right - left) | 0.0 |
0.0 | 2.0 * znear / (top - bottom) | (top + bottom) / (top - bottom) | 0.0 |
0.0 | 0.0 | -(zfar + znear) / (zfar - znear) | -2.0 * zfar * znear / (zfar - znear) |
0.0 | 0.0 | -1.0 | 0.0 |
Arguments
- float left - Left vertical clipping plane.
- float right - Right vertical clipping plane.
- float bottom - Bottom horizontal clipping plane.
- float top - Top horizontal clipping plane.
- float znear - Nearest depth clipping plane.
- float zfar - Farther depth clipping plane.
Return value
Perspective projection matrix.
variable inverse4
(mat4 matrix)
Inverses a matrix that consists of a 3×4 sub-matrix (upper left) and a translation vector. The last row of the matrix is ignored. Compared to the
inverse() function, this one is a bit faster and, which is more important, more stable. A matrix suitable for such inversion looks like this:
m00
|
m10
|
m20
|
m30
|
m01
|
m11
|
m21
|
m31
|
m02
|
m12
|
m22
|
m32
|
0 |
0 |
0 |
1 |
Arguments
- mat4 matrix - Matrix, which will be inversed.
Return value
Inversed
matrix.
mat4 inverse
(mat4 matrix)
Returns inverse of a matrix. Supports
mat4 and
dmat4 arguments.
Arguments
- mat4 matrix - Matrix (either mat4 or dmat4).
Return value
Inversed matrix.
Variable lookAt
(variable position, variable direction, vec3 up)
Returns the viewing matrix from eye point to the direction point with up vector.
Arguments
- variable position - Position of the eye point (vec3 or dvec3).
- variable direction - Position of the reference point (vec3 or dvec3).
- vec3 up - Direction of the up vector.
Return value
Viewing matrix:
- mat4, if the first input argument is vec3
- dmat4 if the first argument is dvec3
Variable obliqueProjection
(mat4 projection, vec4 plane)
Returns the oblique projection matrix.
Arguments
- mat4 projection - Projection matrix.
- vec4 plane - Clipping plane.
Return value
Oblique projection matrix.
mat4 ortho
(float left, float right, float bottom, float top, float znear, float zfar)
Returns parallel projection matrix:
2.0 / (right - left) | 0.0 | 0.0 | -(right + left) / (right - left) |
0.0 | 2.0 / (top - bottom) | 0.0 | -(top + bottom) / (top - bottom) |
0.0 | 0.0 | -2.0 / (zfar - znear) | -(zfar + znear) / (zfar - znear) |
0.0 | 0.0 | 0.0 | 1.0 |
Arguments
- float left - Left vertical clipping plane.
- float right - Right vertical clipping plane.
- float bottom - Bottom horizontal clipping plane.
- float top - Top horizontal clipping plane.
- float znear - Nearest depth clipping plane.
- float zfar - Farther depth clipping plane.
Return value
Parallel projection matrix.
Variable orthonormalize
(variable v)
Orthonormalizes a matrix.
Arguments
- variable v - Matrix (either mat4 or dmat4) to be orthonormalized.
Return value
Orthonormal matrix (either
mat4 or
dmat4 depending on the input argument type).
mat4 perspective
(float fov, float aspect, float znear, float zfar)
Returns perspective projection matrix.
Arguments
- float fov - Field of view angle.
- float aspect - Aspect ratio. The aspect ratio is the ratio of width to height.
- float znear - Nearest depth clipping plane.
- float zfar - Farther depth clipping plane.
Return value
Perspective projection matrix.
Variable reflect
(variable plane)
Returns the reflection matrix.
Arguments
- variable plane - Reflection plane.
Return value
Reflection matrix.
mat4 rotateX
(float angle)
Returns matrix of rotation at the given angle around X axis:
1.0 | 0.0 | 0.0 | 0.0 |
0.0 | cos | -sin | 0.0 |
0.0 | sin | cos | 0.0 |
0.0 | 0.0 | 0.0 | 1.0 |
Arguments
- float angle - Rotation angle, degrees.
Return value
Rotation matrix.
mat4 rotateY
(float angle)
Returns matrix of rotation at the given angle around Y axis:
cos | 0.0 | sin | 0.0 |
0.0 | 1.0 | 0.0 | 0.0 |
-sin | 0.0 | cos | 0.0 |
0.0 | 0.0 | 0.0 | 1.0 |
Arguments
- float angle - Rotation angle, degrees.
Return value
Rotation matrix.
mat4 rotateZ
(float angle)
Returns matrix of rotation at the given angle around Z axis:
cos | -sin | 0.0 | 0.0 |
sin | cos | 0.0 | 0.0 |
0.0 | 0.0 | 1.0 | 0.0 |
0.0 | 0.0 | 0.0 | 1.0 |
Arguments
- float angle - Rotation angle, degrees.
Return value
Rotation matrix.
mat4 rotate
(float x, float y, float z, float angle)
Returns matrix of rotation at the given angle around the axis.
Arguments
- float x - X component of rotation axis.
- float y - Y component of rotation axis.
- float z - Z component of rotation axis.
- float angle - Rotation angle, degrees.
Return value
Rotation matrix.
mat4 rotate
(vec3 axis, float angle)
Returns matrix of rotation at the given angle around the axis.
Arguments
- vec3 axis - Rotation axis.
- float angle - Rotation angle, degrees.
Return value
Rotation matrix.
Variable rotation
(variable v)
Returns rotation matrix of the input matrix, supports
quat,
mat4 and
dmat4 arguments.
Arguments
- variable v - Argument, can be of quat, mat4 or dmat4 type.
Return value
Rotation matrix.
mat4 scale
(float x, float y, float z)
Returns scaling matrix:
x | 0.0 | 0.0 | 0.0 |
0.0 | y | 0.0 | 0.0 |
0.0 | 0.0 | z | 0.0 |
0.0 | 0.0 | 0.0 | 1.0 |
Arguments
- float x - X component of scaling vector.
- float y - Y component of scaling vector.
- float z - Z component of scaling vector.
Return value
Scaling matrix.
mat4 scale
(vec3 vector)
Returns scaling matrix:
scale.x | 0.0 | 0.0 | 0.0 |
0.0 | scale.y | 0.0 | 0.0 |
0.0 | 0.0 | scale.z | 0.0 |
0.0 | 0.0 | 0.0 | 1.0 |
Arguments
- vec3 vector - Scale factor.
Return value
Scaling matrix.
Variable setTo
(variable position, variable direction, vec3 up)
Returns transformation matrix required to place an object into the given point.
Arguments
- variable position - Position of the target point (vec3 or dvec3).
- variable direction - Direction (vec3 or dvec3).
- vec3 up - Direction of the up vector.
Return value
Transformation matrix:
- mat4, if the first input argument is vec3
- dmat4 if the first argument is dvec3
Variable symmetryProjection
(mat4 projection)
Returns the symmetric projection matrix.
Arguments
- mat4 projection - Projection matrix.
Return value
Symmetric projection matrix.
Variable translate
(variable v)
Returns translation matrix:
1.0 | 0.0 | 0.0 | x |
0.0 | 1.0 | 0.0 | y |
0.0 | 0.0 | 1.0 | z |
0.0 | 0.0 | 0.0 | 1.0 |
Arguments
- variable v - Translation vector (either vec3 or dvec3).
Return value
Translation matrix:
- mat4, if the input argument is vec3
- dmat4 if the argument is dvec3
Variable translate
(variable x, variable y, variable z)
Returns translation matrix:
1.0 | 0.0 | 0.0 | x |
0.0 | 1.0 | 0.0 | y |
0.0 | 0.0 | 1.0 | z |
0.0 | 0.0 | 0.0 | 1.0 |
Arguments
- variable x - X component of translation vector (int, float or double).
- variable y - Y component of translation vector (int, float or double).
- variable z - Z component of translation vector (int, float or double).
Return value
Translation matrix:
- mat4, if the first input argument is int or float
- dmat4, if the first argument is double
variable transpose3
(mat4 matrix)
Transposes the upper left 3×3 sub-matrix of a matrix.
Arguments
- mat4 matrix - Matrix, part of which will be transposed.
Return value
matrix, in which the upper left 3×3 sub-matrix is transposed.
mat4 transpose
(mat4 matrix)
Returns transpose matrix of the input matrix:
m00 | m10 | m20 | m30 |
m01 | m11 | m21 | m31 |
m02 | m12 | m22 | m32 |
m03 | m13 | m23 | m33 |
Arguments
Return value
Transposed matrix.