Fixed component swapping in tmat2x2::_inverse().

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).
This commit is contained in:
Tim Howard 2012-10-22 17:23:03 -04:00
parent 5868f20644
commit e2bc911f00

View File

@ -271,8 +271,8 @@ namespace detail
tmat2x2<T> Inverse( tmat2x2<T> Inverse(
+ this->value[1][1] / Determinant, + this->value[1][1] / Determinant,
- this->value[1][0] / Determinant,
- this->value[0][1] / Determinant, - this->value[0][1] / Determinant,
- this->value[1][0] / Determinant,
+ this->value[0][0] / Determinant); + this->value[0][0] / Determinant);
return Inverse; return Inverse;
} }