Fixed math.py inconsistencies #2771
Open
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.
This PR refactors math utilities and related code to use
Point2
tuples consistently instead of mixingx, y
float parameters andPoint2
:Changes
Updated core math functions:
get_distance(x1, y1, x2, y2)
→get_distance(pos1: Point2, pos2: Point2)
rotate_point(x, y, cx, cy, angle)
→rotate_point(point: Point2, center: Point2, angle)
get_angle_degrees
andget_angle_radians
now take Point2 pairs.Fixed
get_angle_radians
: previously usedmath.atan2(x, y)
, now corrected tomath.atan2(y, x)
.Updated all call sites across the codebase (drawing functions, physics, easing, examples, etc.) to use the new signatures.
Improved readability and reduced chance of mismatching parameters.