-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matrix3x2.Invert doesn't actually have tolerance #62714
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-system-numerics Issue Details
Due to the definition of See also https://docs.microsoft.com/en-us/dotnet/api/system.single.epsilon#remarks
|
The check looks like it's just to make sure the determinant isn't zero. Another instance of this pattern actually has a comment: runtime/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.Impl.cs Lines 1276 to 1277 in 5d69e2d
@tannergooding Is there any downside to just changing this to |
Its functionally the same as the current code, but that is itself potentially a bug/issue and likely not the "right" fix. What the code is "meant" to be doing is finding cases where the matrix is "not invertible" and while for strict math that is A "correct" implementation would find the appropriate cutoff and treat values below that threshold as "not invertible", where that threshold can sometimes differ based on the matrix. However, doing that is far too expensive for the use-cases that this type is designed for. Given the cases the type is designed for, more ideally this API would have a signature closer to what GLM, DirectX Math, HLSL, and GLSL provide which includes the result being generally undefined if the value is not inversible, such that it isn't returning a However, since we need to work with what we have the more correct thing would be to define a general epsilon that works for most typical scenarios. A better check would be |
|
runtime/src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix3x2.cs
Line 542 in 22b8d9a
Due to the definition of
float.Epsilon
thisif
will only work for ±0.0f (possibly not even that on ARM with no denormals), but the way the code was written suggests that there's some tolerance involved.See also https://docs.microsoft.com/en-us/dotnet/api/system.single.epsilon#remarks
The text was updated successfully, but these errors were encountered: