Skip to content

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

@Raahi-18

Description

@Raahi-18

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions