arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Bug: get_angle_radians function in math.py returns incorrect angle due to swapped atan2 parameters

Open Raahi-18 opened this issue 5 months ago • 0 comments

The get_angle_radians function has incorrect parameter order in the math.atan2() call at line 454, causing it to return angles rotated by 90 degrees from the expected result.

Incorrect code: return math.atan2(x_diff, y_diff) # Bug: parameters are swapped

Bug example: Getting the angle from (0, 0) to (1, 0) currently returns 1.571 radians (90°) but should return 0.000 radians (0°).

This is a simple one line fix just need to swap the parameters for math.atan2(): return math.atan2(y_diff, x_diff)

I can make a PR for the update.

Raahi-18 avatar Jul 17 '25 17:07 Raahi-18