216 const vm_float_t cofactor_1 = m.
v[5] * m.
v[10] * m.
v[15] - m.
v[5] * m.
v[14] * m.
v[11] - m.
v[9] * m.
v[6] * m.
v[15] +
217 m.
v[9] * m.
v[14] * m.
v[7] + m.
v[13] * m.
v[6] * m.
v[11] - m.
v[13] * m.
v[10] * m.
v[7];
219 const vm_float_t cofactor_2 = -m.
v[4] * m.
v[10] * m.
v[15] + m.
v[4] * m.
v[14] * m.
v[11] + m.
v[8] * m.
v[6] * m.
v[15] -
220 m.
v[8] * m.
v[14] * m.
v[7] - m.
v[12] * m.
v[6] * m.
v[11] + m.
v[12] * m.
v[10] * m.
v[7];
222 const vm_float_t cofactor_3 = m.
v[4] * m.
v[9] * m.
v[15] - m.
v[4] * m.
v[13] * m.
v[11] - m.
v[8] * m.
v[5] * m.
v[15] +
223 m.
v[8] * m.
v[13] * m.
v[7] + m.
v[12] * m.
v[5] * m.
v[11] - m.
v[12] * m.
v[9] * m.
v[7];
225 const vm_float_t cofactor_4 = -m.
v[4] * m.
v[9] * m.
v[14] + m.
v[4] * m.
v[13] * m.
v[10] + m.
v[8] * m.
v[5] * m.
v[14] -
226 m.
v[8] * m.
v[13] * m.
v[6] - m.
v[12] * m.
v[5] * m.
v[10] + m.
v[12] * m.
v[9] * m.
v[6];
228 return m.
v[0] * cofactor_1 + m.
v[1] * cofactor_2 + m.
v[2] * cofactor_3 + m.
v[3] * cofactor_4;
matrix4 mat4_from_mat3(const matrix3 m)
Embeds a matrix3 into the upper-left of a matrix4.
matrix4 mat4_transpose(const matrix4 m)
Computes the transpose of a 4x4 matrix.
matrix4 mat4_perspective_infinite(const vm_float_t fov_y, const vm_float_t aspect, const vm_float_t n)
Constructs an infinite far-plane perspective projection matrix.
matrix4 mat4_scale(const vector3 v)
Constructs a scaling matrix from the given scale vector.
matrix4 mat4_rotation_x(const vm_float_t degrees)
Builds a 4x4 rotation matrix around the X axis (degrees).
vector3 mat4_extract_translation(const matrix4 m)
Extracts the translation vector from a matrix4.
matrix4 mat4_trs(const vector3 translation, const quaternion rotation, const vector3 scale)
Builds a 4x4 TRS matrix from translation, rotation, and scale.
vector4 mat4_mul_vec4(const matrix4 m, const vector4 v)
Multiplies a 4x4 matrix by a vector4.
vector3 mat4_extract_scale(const matrix4 m)
Extracts the scale vector from a matrix4.
matrix4 mat4_rotation_y(const vm_float_t degrees)
Builds a 4x4 rotation matrix around the Y axis (degrees).
matrix4 mat4_rotation(const vector3 axis, const vm_float_t angle)
Constructs a rotation matrix around the given axis by the specified angle (in radians).
matrix4 mat4_identity(void)
Constructs the 4x4 identity matrix.
quaternion mat4_extract_rotation(const matrix4 m)
Extracts the rotation quaternion from a matrix4.
matrix4 mat4_rotation_z(const vm_float_t degrees)
Builds a 4x4 rotation matrix around the Z axis (degrees).
vm_float_t mat4_determinant(const matrix4 m)
Calculates the determinant of the given 4x4 matrix.
matrix4 mat4_inverse(const matrix4 m)
Computes the inverse of a 4x4 matrix.
matrix4 mat4_mul(const matrix4 a, const matrix4 b)
Multiplies two 4x4 matrices (a * b).
matrix4 mat4_perspective(const vm_float_t fov, const vm_float_t aspect, const vm_float_t near, const vm_float_t far)
Constructs a perspective projection matrix.
vector3 mat4_mul_vec3(const matrix4 m, const vector3 v, const vm_float_t w)
Transforms a vector3 by a 4x4 matrix using homogeneous w.
matrix4 mat4_perspective_fov(const vm_float_t fov, const vm_float_t w, const vm_float_t h, const vm_float_t n, const vm_float_t f)
Constructs a perspective projection matrix using FOV, width, and height.
matrix4 mat4_translate(const vector3 v)
Constructs a translation matrix from the given vector.
matrix4 mat4_ortho(const vm_float_t left, const vm_float_t right, const vm_float_t bottom, const vm_float_t top, const vm_float_t near, const vm_float_t far)
Constructs an orthographic projection matrix.
matrix4 mat4_look_at(const vector3 position, const vector3 target, const vector3 up)
Constructs a view matrix from eye position, target, and up vector.
vm_float_t v[VECMAT_MAT4_SIZE]
void mat4_mul_vec3_ptr(vector3 *res, const matrix4 *m, const vector3 *v, vm_float_t w)
void mat4_ortho_ptr(matrix4 *res, vm_float_t left, vm_float_t right, vm_float_t bottom, vm_float_t top, vm_float_t near, vm_float_t far)
Sets the matrix to an orthographic projection matrix.
void mat4_rotation_x_ptr(matrix4 *res, vm_float_t degrees)
Builds a 4x4 rotation matrix around the X axis (degrees).
void mat4_scale_ptr(matrix4 *res, const vector3 *v)
Sets the matrix to a scaling matrix using the provided scale vector.
void mat4_mul_vec4_ptr(vector4 *res, const matrix4 *m, const vector4 *v)
void mat4_extract_scale_ptr(vector3 *res, const matrix4 *m)
Extracts the scale vector from a matrix4.
void mat4_look_at_ptr(matrix4 *res, const vector3 *position, const vector3 *target, const vector3 *up)
Constructs a view matrix for a camera positioned at the given location, looking towards a target,...
void mat4_rotation_ptr(matrix4 *res, const vector3 *axis, vm_float_t angle)
Sets the matrix to a rotation matrix around the specified axis by the given angle.
void mat4_extract_rotation_ptr(quaternion *res, const matrix4 *m)
Extracts the rotation quaternion from a matrix4.
void mat4_inverse_ptr(matrix4 *res, const matrix4 *m)
Computes the inverse of a 4x4 matrix.
void mat4_perspective_fov_ptr(matrix4 *res, vm_float_t fov, vm_float_t w, vm_float_t h, vm_float_t n, vm_float_t f)
Sets the matrix to a perspective projection matrix.
void mat4_perspective_infinite_ptr(matrix4 *res, vm_float_t fov_y, vm_float_t aspect, vm_float_t n)
Sets the matrix to an infinite perspective projection matrix.
void mat4_rotation_z_ptr(matrix4 *res, vm_float_t degrees)
Builds a 4x4 rotation matrix around the Z axis (degrees).
void mat4_translate_ptr(matrix4 *res, const vector3 *v)
Sets the matrix to a translation matrix.
void mat4_extract_translation_ptr(vector3 *res, const matrix4 *m)
Extracts the translation vector from a matrix4.
void mat4_transpose_ptr(matrix4 *res, const matrix4 *m)
void mat4_from_mat3_ptr(matrix4 *res, const matrix3 *m)
Embeds a matrix3 into the upper-left of a matrix4.
void mat4_mul_ptr(matrix4 *res, const matrix4 *a, const matrix4 *b)
void mat4_perspective_ptr(matrix4 *res, vm_float_t fov, vm_float_t aspect, vm_float_t near, vm_float_t far)
Creates a perspective projection matrix.
void mat4_identity_ptr(matrix4 *res)
Sets the matrix to the identity matrix.
void mat4_trs_ptr(matrix4 *res, const vector3 *translation, const quaternion *rotation, const vector3 *scale)
Builds a 4x4 TRS matrix from translation, rotation, and scale.
void mat4_rotation_y_ptr(matrix4 *res, vm_float_t degrees)
Builds a 4x4 rotation matrix around the Y axis (degrees).