mirror of
https://github.com/recp/cglm.git
synced 2025-12-31 20:56:07 +00:00
mat3 determinant
This commit is contained in:
@@ -152,6 +152,28 @@ glm_mat3_scale(mat3 m, float s) {
|
||||
m[2][0] *= s; m[2][1] *= s; m[2][2] *= s;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief mat3 determinant
|
||||
*
|
||||
* @param[in] mat matrix
|
||||
*
|
||||
* @return determinant
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_mat3_det(mat3 mat) {
|
||||
/* [square] det(A) = det(At) */
|
||||
float a, b, c,
|
||||
d, e, f,
|
||||
g, h, i;
|
||||
|
||||
a = mat[0][0], b = mat[0][1], c = mat[0][2],
|
||||
d = mat[1][0], e = mat[1][1], f = mat[1][2],
|
||||
g = mat[2][0], h = mat[2][1], i = mat[2][2];
|
||||
|
||||
return a * (e * i - h * f) - d * (b * i - c * h) + g * (b * f - c * e);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief inverse mat3 and store in dest
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user