sharpdx/SharpDX — pull request #63 by VirusFree (2013-04-05 11:44:12+00:00)
Title: MathUtil.ZeroTolerance is too high for determinant, Matrix.Invert() gives incorrect results

The problem is easy to reproduce, try this code :
var m = Matrix.Scaling(0.01f);
var im = Matrix.Invert(m);

The resulting inverted matrix im should have scale 100 , but instead you end up with a zero matrix ( Matrix.Zero ).

the problem is in this code in Matrix.cs Invert()
if (Math.Abs(det) <= MathUtil.ZeroTolerance)
{
result = Matrix.Zero;
return;
}

I didn't want to change the ZeroTolerance threshold itself because it may cause other side-effect .. so i just lower it more in this check.. (see commit)

Actually this threshold could be event lower because it's always better to get "some" results (even if not that precise) than destroying the entire matrix...
(but of course protect against infinity when doing 1/det later on).