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 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: 8

Rounding precision (digits)

transform-translate

transform-translate() 

Returns a

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

x-shear matrix

factor:

The shear in the

direction.

transform-shear-z

transform-shear-z() 

Returns a

z-shear matrix

factor:

The shear in the

direction.

transform-scale

transform-scale() 

Returns a

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

rotation xyz matrix for a direction and up vector

idk

idk

transform-rotate-x

transform-rotate-x() 

Returns a

rotation matrix

angle:

The angle to rotate around the

axis

transform-rotate-y

transform-rotate-y() 

Returns a

rotation matrix

angle:

The angle to rotate around the

axis

transform-rotate-z

transform-rotate-z() 

Returns a

rotation matrix

angle:

The angle to rotate around the

axis

transform-rotate-aer

transform-rotate-aer() 

Returns a

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

rotation matrix

The angle to rotate around the

axis

The angle to rotate around the

axis

transform-rotate-ypr

transform-rotate-ypr() 

Returns a

rotation matrix - yaw-pitch-roll

Yaw

Pitch

Roll

transform-rotate-xyz

transform-rotate-xyz() 

Returns a

rotation matrix - euler angles

Calculates the product of the three rotation matrices

Rotation about x

Rotation about y

Rotation about z

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

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

. Prefer the use of mul4x4-vec3 when possible as it does not use loops.

The matrix to multiply

The vector to multiply

inverse

inverse() 

Calculates the inverse matrix of any size.

matrix:

The matrix to inverse.