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() -> matrix 

Create identity matrix with dimensions m×nm \times n

m:

Default: 4

The number of rows

n:

Default: 4

The number of columns

one:

Default: 1

Value to set as 11

zero:

Default: 0

Value to set as 00

dim

dim() -> array 

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

The matrix

column

column() -> vector 

Returns the nth column of a matrix as a vector

Input matrix

The column's index

set-column

set-column() -> matrix 

Replaces the nth column of a matrix with the given vector.

Input matrix.

The index of the column to replace

The column data to insert.

round

round() -> matrix 

Rounds each value in the matrix to a precision.

Input matrix

precision:

Default: 8

Rounding precision (digits)

transform-translate

transform-translate() -> matrix 

Returns a 4×44 \times 4 translation matrix

The translation in the xx direction.

The translation in the yy direction.

The translation in the xx direction.

transform-shear-x

transform-shear-x() -> matrix 

Returns a 4×44 \times 4 x-shear matrix

factor:

The shear in the xx direction.

transform-shear-z

transform-shear-z() -> matrix 

Returns a 4×44 \times 4 z-shear matrix

factor:

The shear in the zz direction.

transform-scale

transform-scale() -> matrix 

Returns a 4×44 \times 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() -> matrix 

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

idk

idk

transform-rotate-x

transform-rotate-x() -> matrix 

Returns a 4×44 \times 4 xx rotation matrix

angle:

The angle to rotate around the xx axis

transform-rotate-y

transform-rotate-y() -> matrix 

Returns a 4×44 \times 4 yy rotation matrix

angle:

The angle to rotate around the yy axis

transform-rotate-z

transform-rotate-z() -> matrix 

Returns a 4×44 \times 4 zz rotation matrix

angle:

The angle to rotate around the zz axis

transform-rotate-xz

transform-rotate-xz() -> matrix 

Returns a 4×44 \times 4 xzx z rotation matrix

The angle to rotate around the xx axis

The angle to rotate around the zz axis

transform-rotate-ypr

transform-rotate-ypr() -> matrix 

Returns a 4×44 \times 4 rotation matrix - yaw-pitch-roll

Calculates the product of the three rotation matrices R=Rz(a)Ry(b)Rx(c)R = Rz(a) Ry(b) Rx(c)

Yaw

Pitch

Roll

transform-rotate-xyz

transform-rotate-xyz() -> matrix 

Returns a 4×44 \times 4 rotation matrix - euler angles

Calculates the product of the three rotation matrices R=Rz(z)Ry(y)Rx(x)R = Rz(z) Ry(y) Rx(x)

Rotation about x

Rotation about y

Rotation about z

mul-mat

mul-mat() -> matrix 

Multiplies matrices on top of each other.

..matrices:

The matrices to multiply from left to right.

mul4x4-vec3

mul4x4-vec3() -> vector 

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

The matrix to multiply

The vector to multiply

Default: 1

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

mul-vec

mul-vec() -> vector 

Multiplies an m×nm \times n matrix with an mmth dimensional vector where m\lte4m \lte 4. Prefer the use of mul4x4-vec3 when possible as it does not use loops.

The matrix to multiply

The vector to multiply

inverse

inverse() -> matrix 

Calculates the inverse matrix of any size.

matrix:

The matrix to inverse.

swap-cols

swap-cols() -> matrix 

Swaps the ath column with the bth column.

Matrix

The index of column a.

The index of column b.

translate

translate() 

Translates a matrix by a vector.

The matrix to translate

The vector to translate by.