const precision = f32(10e-7)
fn abs(a f32) f32
fn add(a Mat4, b Mat4) Mat4
Sum of matrix function
fn blank_v4() Vec4
Return a blank vector
fn calc_tr_matrices(w f32, h f32, rx f32, ry f32, in_scale f32) Mat4
Get the complete transformation matrix for GLSL demos
fn deg(grad f32) f32
Translate radians to degrees
fn det(x Mat4) f32
Calculate the determinant of the Matrix
fn look_at(eye Vec4, center Vec4, up Vec4) Mat4
Calculate the look-at matrix
fn mul(a Mat4, b Mat4) Mat4
Multiplication of matrix function
fn mul_vec(a Mat4, v Vec4) Vec4
Multiply a Matrix by a vector
fn one_v4() Vec4
Return all one vector
fn perspective(fov f32, ar f32, n f32, f f32) Mat4
Calculate the perspective matrix
fn rad(deg f32) f32
Translate degrees to radians
fn rotate(angle f32, w Vec4) Mat4
Get a rotation matrix using w as rotation axis vector, the angle is in radians
fn scale(w Vec4) Mat4
Get a scale matrix, the scale vector is w, only xyz are evaluated.
fn set_m4(value f32) Mat4
Return a matrix initialized with value
fn set_v4(value f32) Vec4
Set all elements to value
fn sub(a Mat4, b Mat4) Mat4
Subtraction of matrix function
fn unit_m4() Mat4
Return a unity matrix
fn zero_m4() Mat4
Return a zero matrix
fn zero_v4() Vec4
Return a zero vector
union Mat4 {
pub mut:
e [16]f32
f [4][4]f32
}
fn (x Mat4) str() string
String representation of the matrix
fn (a Mat4) clean() Mat4
Remove all the raw zeros
fn (x Mat4) sum_all() f32
Sum all the elements of the matrix
fn (x Mat4) is_equal(y Mat4) bool
Check if two matrix are equal using module precision
fn (x Mat4) get_e(elem_index int) f32
------------------------------------- Set/Get values ------------------------------------- Get an element of the matrix using [0..15] indexes, one dimension
fn (x Mat4) get_f(index_col int, index_row int) f32
Get an element of the matrix using [0..3][0..3] indexes, two dimension
fn (mut x Mat4) set_e(index int, value f32)
Set an element of the matrix using [0..15] indexes, one dimension
fn (mut x Mat4) set_f(index_col int, index_row int, value f32)
Set an element of the matrix using [0..3][0..3] indexes, two dimension
fn (mut x Mat4) copy(y Mat4)
Copy a matrix elements from another matrix
fn (mut x Mat4) set_trace(v3 Vec4)
Set the trace of the matrix using a vec4
fn (x Mat4) get_trace() Vec4
Get the trace of the matrix
fn (mut x Mat4) set_f32(value f32)
Set all the matrix elements to value
fn (mut x Mat4) set_row(row int, v3 Vec4)
------------------------------------- Rows/Column access ------------------------------------- Set the row as the input vec4
fn (x Mat4) get_row(row int) Vec4
Get a row from a matrix
fn (mut x Mat4) set_col(col int, v3 Vec4)
Set the column as the input vec4
fn (x Mat4) get_col(col int) Vec4
Get a column from a matrix
fn (mut x Mat4) swap_col(col1 int, col2 int)
Swap two columns in the matrix
fn (mut x Mat4) swap_row(row1 int, row2 int)
Swap two rows in the matrix
fn (x Mat4) transpose() Mat4
------------------------------------- Modify data ------------------------------------- Transpose the matrix
fn (x Mat4) mul_scalar(s f32) Mat4
Multiply the all the elements of the matrix by a scalar
fn (a Mat4) + (b Mat4) Mat4
Sum of matrix, operator +
fn (a Mat4) - (b Mat4) Mat4
Subtraction of matrix, operator -
fn (a Mat4) * (b Mat4) Mat4
Multiplication of matrix, operator *
fn (x Mat4) inverse() Mat4
Calculate the inverse of the Matrix
fn (x Mat4) translate(w Vec4) Mat4
Get a matrix translated by a vector w
struct Vec4 {
pub mut:
e [4]f32
}
fn (x Vec4) str() string
fn (a Vec4) clean() Vec4
Remove all the raw zeros
fn (mut x Vec4) copy(value f32)
Set all elements to value
fn (x Vec4) mul_scalar(value f32) Vec4
Scale the vector using a scalar
fn (x Vec4) inv() Vec4
Reciprocal of the vector
fn (x Vec4) normalize() Vec4
Normalize the vector
fn (x Vec4) normalize3() Vec4
Normalize only xyz, w set to 0
fn (x Vec4) mod() f32
Module of the vector xyzw
fn (x Vec4) mod3() f32
Module for 3d vector xyz, w ignored
fn (x Vec4) sum() f32
Sum of all the elements
fn (a Vec4) + (b Vec4) Vec4
Addition
fn (a Vec4) - (b Vec4) Vec4
Subtraction
fn (a Vec4) * (b Vec4) f32
Dot product
fn (a Vec4) % (b Vec4) Vec4
Cross product
fn (x Vec4) mul_vec4(y Vec4) Vec4
Components multiplication