Matrix
4x4 row-major float matrix
It
Matrix object (16 floats, initialized to identity)
struct It {
F32 values[16]
};setIdentity
Reset a matrix to the identity matrix
U0 setIdentity(Matrix mat)Parameters
mat— The matrix to reset
multiply
Multiply two matrices and store the result
U0 multiply(Matrix result, Matrix left, Matrix right)Parameters
result— Matrix to store the resultleft— First (left) matrixright— Second (right) matrix
copy
Copy a matrix into another
U0 copy(Matrix src, Matrix dest)Parameters
src— Source matrixdest— Destination matrix
ortho2D
Build a 2D orthographic projection matrix
U0 ortho2D(Matrix mat, F32 left, F32 right, F32 bottom, F32 top, F32 near, F32 far)Parameters
mat— Output matrixleft— Left boundaryright— Right boundarybottom— Bottom boundarytop— Top boundarynear— Near planefar— Far plane
ortho2DVk
Build a 2D orthographic projection matrix adjusted for Vulkan's coordinate system
U0 ortho2DVk(Matrix mat, F32 left, F32 right, F32 bottom, F32 top, F32 near, F32 far)Parameters
mat— Output matrixleft— Left boundaryright— Right boundarybottom— Bottom boundarytop— Top boundarynear— Near planefar— Far plane
projection
Build a 3D perspective projection matrix
U0 projection(Matrix mat, F32 width, F32 height, F32 fov, F32 near, F32 far)Parameters
mat— Output matrixwidth— Viewport widthheight— Viewport heightfov— Field of view angle in radiansnear— Near plane distancefar— Far plane distance
scale
Apply a scale transform to a matrix
U0 scale(Matrix mat, F32 x, F32 y, F32 z, F32 w)Parameters
mat— Matrix to modifyx— X scale factory— Y scale factorz— Z scale factorw— W scale factor
translate
Apply a translation transform to a matrix
U0 translate(Matrix mat, F32 x, F32 y, F32 z, F32 w)Parameters
mat— Matrix to modifyx— X translationy— Y translationz— Z translationw— W translation
rotate
Apply a rotation transform to a matrix
U0 rotate(Matrix mat, F32 angle, F32 x, F32 y, F32 z)Parameters
mat— Matrix to modifyangle— Rotation angle in radiansx— X axis weighty— Y axis weightz— Z axis weight
lookAt
Build a view matrix from eye position, target, and up vector
U0 lookAt(Matrix mat, VectorF eye, VectorF center, VectorF up)Parameters
mat— Output view matrixeye— Camera positioncenter— Camera target pointup— World up direction