Math inversion used to return zero (math_inv3x3) or error (math_invert3x3) for negative determinant. Now checking whether the absolute(!) value of the determinant is close to zero to avoid singularities, negative determinants are very well allowed.

This commit is contained in:
Christoph Kords 2011-12-14 08:55:24 +00:00
parent 4faded6297
commit b2547e0117
1 changed files with 2 additions and 2 deletions

View File

@ -757,7 +757,7 @@ pure function math_transpose3x3(A)
- A(1,2) * (A(2,1) * A(3,3) - A(2,3) * A(3,1))&
+ A(1,3) * (A(2,1) * A(3,2) - A(2,2) * A(3,1))
if (DetA > tiny(DetA)) then
if (abs(DetA) > tiny(abs(DetA))) then
math_inv3x3(1,1) = ( A(2,2) * A(3,3) - A(2,3) * A(3,2)) / DetA
math_inv3x3(2,1) = (-A(2,1) * A(3,3) + A(2,3) * A(3,1)) / DetA
math_inv3x3(3,1) = ( A(2,1) * A(3,2) - A(2,2) * A(3,1)) / DetA
@ -796,7 +796,7 @@ pure function math_transpose3x3(A)
- A(1,2) * (A(2,1) * A(3,3) - A(2,3) * A(3,1))&
+ A(1,3) * (A(2,1) * A(3,2) - A(2,2) * A(3,1))
if (DetA <= tiny(DetA)) then
if (abs(DetA) <= tiny(abs(DetA))) then
error = .true.
else
InvA(1,1) = ( A(2,2) * A(3,3) - A(2,3) * A(3,2)) / DetA