Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 4 commits into from
Aug 7, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove unnecessary math in Path.arc.
These trig bits were necessary to properly scale by major and minor axes
for an ellipse, but this method only supports circular arcs.
  • Loading branch information
QuLogic committed Aug 6, 2017
commit 87c668ac9d28dba7cccc536b4568b8fe7a20076f
9 changes: 3 additions & 6 deletions lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,14 +864,11 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False):
polylines, quadratic or cubic Bezier curves
<http://www.spaceroots.org/documents/ellipse/index.html>`_.
"""
theta1, theta2 = np.deg2rad([theta1, theta2])

twopi = np.pi * 2.0
halfpi = np.pi * 0.5

eta1 = np.arctan2(np.sin(theta1), np.cos(theta1))
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)
Copy link
Member

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 // ?

Copy link
Member Author

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.)

eta1, eta2 = np.deg2rad([eta1, eta2])

# number of curve segments to make
if n is None:
Expand Down