Repository navigation
Conversation
JayPokale
requested review from
Panquesito7,
alexpantyukhin and
tjgurwara99
as code owners
November 27, 2026 09:42
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
to_polarreturned a wrong angle in two cases:x > 0, y < 0):atan(y / x)is already the right (negative) angle, but the code returned2 * pi - atan(y / x). For(2, -1)it gave 6.7468 instead of -0.4636.x == -y,x < 0): the Q1 condition|| (x == -y)caught it, so(-1, 1)gave -pi/4 instead of 3pi/4.Fix: drop the
x == -yclause from the Q1 check and use*thetafor Q4. Addedtest_quadrants(), which checks r and theta againsthypot/atan2for points in every quadrant, both diagonals and the axes.Before: the file's own assertion
fabs(theta - atan2(y, x)) < 0.01already aborts on master here (Q4 points fromrand), and the new test fails.After: both
test()andtest_quadrants()pass, also with-fsanitize=address,undefined; clang-format is clean.References
Fixes #1582
Checklist
Notes: Fixes the wrong angle for Q4 and anti-diagonal inputs in to_polar.