-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Ensure that Path.arc works for any full circle. #8994
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
These trig bits were necessary to properly scale by major and minor axes for an ellipse, but this method only supports circular arcs.
Depending on the inputs, the range may get squashed down to ~0 when trying to remove extra 2pi revolutions. Fixes matplotlib#8992.
These are a bit unfortunate since they're mostly invisible.
eta2 = np.arctan2(np.sin(theta2), np.cos(theta2)) | ||
eta2 -= twopi * np.floor((eta2 - eta1) / twopi) | ||
eta1 = theta1 | ||
eta2 = theta2 - 360 * np.floor((theta2 - theta1) / 360) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use floor instead of //
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few edge cases where it's not the same, but I'm not sure if that's the reason. This is just a rearrangment of existing code changed from radians to degrees (because the trig is not necessary here.)
I forgot to comment after pushing, but I found that there's some trig that's unnecessary which produces some small floating-point inconsistencies. It's there to scale by ellipses major & minor axes, but |
Can you add a note to the docstring that this always draws from theta1 -> theta2 clockwise and winding at most once? I don't think this is a change of behavior, but there is some ambiguity as to what it should do (for example it could wind multiple times (which I don't think any one wants) or it could always connect them via the shortest route (which I also think no one wants)). |
That's correct; it's the existing behaviour, and I've added some lines explaining it. |
Depending on the inputs, the range may get squashed down to ~0 when trying to remove extra 2pi revolutions.
This condition is part of implementation linked in the docstring for
Path.arc
but is not included here for some reason.Fixes #8992.
PR Checklist