-
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
Fix Matrix4x4.CreateReflection when D is not zero #110057
Conversation
I think we should revert to the Plane plane = new Plane(0, 1, 0, 60);
Matrix4x4 actual = Matrix4x4.CreateReflection(plane);
Console.WriteLine(Equal(1.0f, actual.M11));
Console.WriteLine(Equal(0.0f, actual.M12));
Console.WriteLine(Equal(0.0f, actual.M13));
Console.WriteLine(Equal(0.0f, actual.M14));
Console.WriteLine(Equal(0.0f, actual.M21));
Console.WriteLine(Equal(-1.0f, actual.M22));
Console.WriteLine(Equal(0.0f, actual.M23));
Console.WriteLine(Equal(0.0f, actual.M24));
Console.WriteLine(Equal(0.0f, actual.M31));
Console.WriteLine(Equal(0.0f, actual.M32));
Console.WriteLine(Equal(1.0f, actual.M33));
Console.WriteLine(Equal(0.0f, actual.M34));
Console.WriteLine(Equal(-0.0f, actual.M41));
Console.WriteLine(Equal(-120.0f, actual.M42));
Console.WriteLine(Equal(-0.0f, actual.M43));
Console.WriteLine(Equal(1.0f, actual.M44));
(bool, string) Equal(float a, float b)
{
if (a.ToString() == b.ToString()) return (true, "ok");
return (false, $"expected: {a}, actual: {b}");
} On .NET 9 with this PR:
On .NET 8:
On .NET 7:
On .NET 6:
Also, the precision of the existing test is an issue as well:
I want to minimize the change given that this PR need to be backported to .NET 9. I'm reverting the changes to tests. |
Determinism with -0 vs +0 is actually relevant and expected The general issue is that the pre-existing CreateReflection01 test is “bad” and is essentially testing the output is the same as base math, which is faulty and not itself “correct” I’d be fine with leaving the existing test using the helper to minimize PR churn, but the new test should be strictly doing the right thing here |
6f15560
to
db16a0c
Compare
Test failures are unrelated. @tannergooding PTAL |
/backport to release/9.0-staging |
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/12018037447 |
* Fix Matrix4x4.CreateReflection * Update tests * Use AssertExtensions instead * Update Matrix4x4Tests.cs * Update Matrix4x4Tests.cs * Use AssertExtensions for new test only --------- Co-authored-by: Tanner Gooding <tagoo@outlook.com>
This is a correctness regression from .NET 8 which was introduced in #103527.
Fixed it and added a regression test for it.
Fixes #110050