From e2bc911f0053c213f34614964d374182cb3f8dc0 Mon Sep 17 00:00:00 2001 From: Tim Howard Date: Mon, 22 Oct 2012 17:23:03 -0400 Subject: [PATCH] Fixed component swapping in tmat2x2::_inverse(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NB: glm::detail::tmat2x2::_inverse() incorrectly swaps all components instead of only main diagonals: A = ⌈a b⌉ ⌊c d⌋ (using standard representation). _inverse() on A incorrectly gives the order ⌈ d -c⌉ ⌊-b a⌋ (swaps both diagonals) where it should be ⌈ d -b⌉ ⌊-c a⌋ (I am leaving out division by the determinate for clarity). Also, glm::inverse() in `glm/core/func_matrix.inl` is correct for 2x2 matrices and shows the mistake of _inverse(). The unit tests do not appear to test division of a mat2 by a mat2 (where this could arise). --- glm/core/type_mat2x2.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index a6227297..7a66a3e7 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -271,8 +271,8 @@ namespace detail tmat2x2 Inverse( + this->value[1][1] / Determinant, + - this->value[0][1] / Determinant, - this->value[1][0] / Determinant, - - this->value[0][1] / Determinant, + this->value[0][0] / Determinant); return Inverse; }