-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Implement Matrix.CreateRotation with center point. #17657
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
Conversation
You can test this PR using the following package version. |
Please double check Radians vs. Degrees for API uniformity. Higher levels usually use degrees. It is very important we keep APIs consistent in terms of units. |
I think the other rotation api uses radians. |
@rabbitism All our shape API uses degrees. API in WPF almost always uses degrees. I don't know the Matrix API off the top of my head but we need to 1) Use degrees or 2) Use radians if that is what WPF does in this case. This is something that has to be very carefully reviewed in API because both degree and radian are double. So it's a very dangerous silently breaking changing if ever it needs to be fixed. |
I don't see any reason this API should use a different unit with the other. Avalonia/src/Avalonia.Base/Matrix.cs Lines 210 to 215 in f4633e2
|
Well, seems we are already different from WPF... I wonder if this was intentional or an oversight. I guess the one benefit is radians makes the math easier. Still, we really shouldn't have both degrees and radians in the APIs. The convention has always been degrees as well. If we wanted to switch to radians it should have been done everywhere. But it is worse to have different units in the same class. So now we are stuck. API review is extremely important. There should NOT be a public degrees to radians conversion method on this class either. |
Matrix APIs in .NET BCL and SkiaSharp use radians |
This method is 10 years old... Shouldn't be there indeed. |
@maxkatz6 OK, if they already use radians in the BCL I won't argue. My point was WPF seems to be different using degrees. Perhaps Microsoft changed their thinking for .NET after WPF was initially released. I guess the distinction is: Low-level functionality uses Radians for mathematical reasons. High-level API (XAML/Shapes) uses degrees for compatibility and simplicity (degrees are easier for people to visualize). |
What does the pull request do?
Add new overload for Matrix.CreateRotation(double radians, Point center).
This is a valid and commonly used transformation in SVG see: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#rotate
Also part of Systme.Numeric api.
Notice: whether to use
Point
orVector
is not finalized yet, pending on team descision.What is the current behavior?
What is the updated/expected behavior with this PR?
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues
Closes #17307