This page has been translated automatically.
UnigineScript
The Language
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Math Matrix Functions

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.02.0 * znear / (top - bottom)(top + bottom) / (top - bottom)0.0
0.00.0-(zfar + znear) / (zfar - znear)-2.0 * zfar * znear / (zfar - znear)
0.00.0-1.00.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.00.0-(right + left) / (right - left)
0.02.0 / (top - bottom)0.0-(top + bottom) / (top - bottom)
0.00.0-2.0 / (zfar - znear)-(zfar + znear) / (zfar - znear)
0.00.00.01.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.00.00.00.0
0.0cos-sin0.0
0.0sincos0.0
0.00.00.01.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:
cos0.0sin0.0
0.01.00.00.0
-sin0.0cos0.0
0.00.00.01.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-sin0.00.0
sincos0.00.0
0.00.01.00.0
0.00.00.01.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:
x0.00.00.0
0.0y0.00.0
0.00.0z0.0
0.00.00.01.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.x0.00.00.0
0.0scale.y0.00.0
0.00.0scale.z0.0
0.00.00.01.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.00.00.0x
0.01.00.0y
0.00.01.0z
0.00.00.01.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.00.00.0x
0.01.00.0y
0.00.01.0z
0.00.00.01.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:
m00m10m20m30
m01m11m21m31
m02m12m22m32
m03m13m23m33

Arguments

  • mat4 matrix - Argument.

Return value

Transposed matrix.
Last update: 2017-07-03
Build: ()