Skip to main content

matrix

An array of arrays of floats that represent a matrix. Can be any size but transformation matrices are 4x4.

ident​

ident() 

Create a (square) identity matrix with dimensions size×size

size:

​

Size of the matrix

diag​

diag() 

Create a square matrix with the diagonal set to the given values

..diag:

​

Diagonal values

dim​

dim() 

Returns the dimension of the given matrix as (m, n)

The matrix

column​

column() 

Returns the n-th column of a matrix as a vector

Input matrix

The column’s index

round​

round() 

Rounds each value in the matrix to a precision.

Input matrix

precision:

Default: 10​

Rounding precision (digits)

mul-mat​

mul-mat() 

Multiplies matrices on top of each other.

..matrices:

​

The matrices to multiply from left to right.

mul4x4-vec3​

mul4x4-vec3() 

Multiplies a 4×4 matrix with a vector of size 3 or 4. The resulting is three dimensional

The matrix to multiply

The vector to multiply

The default value for the fourth element of the vector if it is three dimensional.

mul-vec​

mul-vec() 

Multiplies an 𝑚×𝑛 matrix with an 𝑚th dimensional vector where 𝑚≤4. Prefer the use of mul4x4-vec3 when possible as it does not use loops.

The matrix to multiply

The vector to multiply

is-identity​

is-identity() 

Returns true if m is 1.

Matrix to check

inverse​

inverse() 

Calculates the inverse matrix of any size.

matrix:

​

The matrix to inverse.

transform-translate​

transform-translate() 

Returns a 4×4 translation matrix

The translation in the 𝑥 direction.

The translation in the 𝑦 direction.

The translation in the 𝑥 direction.

transform-shear-x​

transform-shear-x() 

Returns a 4×4 x-shear matrix

factor:

​

The shear in the 𝑥 direction.

transform-shear-z​

transform-shear-z() 

Returns a 4×4 z-shear matrix

factor:

​

The shear in the 𝑧 direction.

transform-scale​

transform-scale() 

Returns a 4×4 scale matrix

The scale factor(s) of the matrix. An array of at least 3 floats sets the x, y and z scale factors. A dictionary sets the scale in the direction of the corresponding x, y and z keys. A single float sets the scale for all directions.

transform-rotate-dir​

transform-rotate-dir() 

Returns a 4×4 rotation xyz matrix for a direction and up vector

idk

idk

transform-rotate-x​

transform-rotate-x() 

Returns a 4×4 𝑥 rotation matrix

angle:

​

The angle to rotate around the 𝑥 axis

transform-rotate-y​

transform-rotate-y() 

Returns a 4×4 𝑦 rotation matrix

angle:

​

The angle to rotate around the 𝑦 axis

transform-rotate-z​

transform-rotate-z() 

Returns a 4×4 𝑧 rotation matrix

angle:

​

The angle to rotate around the 𝑧 axis

transform-rotate-aer​

transform-rotate-aer() 

Returns a 4×4 rotation matrix from azimuth/elevation/roll. Assumes the viewing convention where 𝑧 points up and 𝑥 points toward the viewer.

azimuth:

​

Rotation around z.

elevation:

​

Tilt above the xy plane.

roll:

​

Rotation around the current viewing axis.

transform-rotate-xz​

transform-rotate-xz() 

Returns a 4×4 𝑥𝑧 rotation matrix

The angle to rotate around the 𝑥 axis

The angle to rotate around the 𝑧 axis

transform-rotate-ypr​

transform-rotate-ypr() 

Returns a 4×4 rotation matrix - yaw-pitch-roll

Yaw

Pitch

Roll

transform-rotate-xyz​

transform-rotate-xyz() 

Returns a 4×4 rotation matrix - euler angles

Calculates the product of the three rotation matrices 𝑅=𝑅𝑧(𝑧)𝑅𝑦(𝑦)𝑅𝑥(𝑥)

Rotation about x

Rotation about y

Rotation about z