-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Fix bug with Polygon.angles #24960
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 bug with Polygon.angles #24960
Conversation
Changes address issue sympy#24885. To find the angles of a polygon without making assumptions about it, you have to take into account all of its vertices in some way. Consider that if you were given a polygon with one vertex removed, it would be impossible to tell which angles were the interior angles and which angles were the conjugates of the interior angles. Previously the code determined the orientation of the polygon by checking the orientation of only one of the angles of the polygon. I believe the method used might work if the polygon is assumed to be convex but definitely does not work in all cases. The new code uses the fact that the sum of the interior angles of any polygon is always (n-2)*180. If the computed angles don’t sum up to this, the angles function returns the conjugates of the wrong angels instead. I also renamed _isright to _is_clockwise to avoid confusion and better reflect what the function does. A note on terminology: the conjugate of an angle x is 360 -x; conjugate angles are pairs of angles that add up to 360 degrees. Co-authored-by: smichr
✅ Hi, I am the SymPy bot. I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.13. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) before after ratio
[8bd31f66] [7e537b0c]
<sympy-1.12rc1^0>
- 83.6±0.8ms 54.2±0.2ms 0.65 integrate.TimeIntegrationRisch02.time_doit(10)
- 82.3±0.6ms 53.6±0.2ms 0.65 integrate.TimeIntegrationRisch02.time_doit_risch(10)
Full benchmark results can be found as artifacts in GitHub Actions |
Thanks. This will merge when tests finish. |
References to other Issues or PRs
Fixes #24885
Brief description of what is fixed or changed
For some cases, Polygon.angles returned the conjugates of the interior angles (2pi - interior angle) because it could not determine the orientation of the polygon correctly. The fix checks the sum of the computed angles against (n-2)*pi, what the interior angles should sum up to. If this sums up to the wrong value, (n+2)*pi, then the conjugates of the computed angles are returned.
Other comments
Also renamed Polygon._isright method to Polygon._is_clockwise for clarity and to avoid confusion with Triangle.is_right.
Release Notes