From 06393513cab30b5f2970213ad8112db5044d306a Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Wed, 12 Oct 2016 12:20:10 +0300 Subject: [PATCH] mat3 determinant --- include/cglm-mat3.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/cglm-mat3.h b/include/cglm-mat3.h index da27989..f3d8583 100644 --- a/include/cglm-mat3.h +++ b/include/cglm-mat3.h @@ -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 *