Skip to content

Commit 8ae1808

Browse files
committed
Fix angle and rotation bugs in math utils: corrected get_angle_radians argument order, fixed rotate_around_point offset, converted degrees to radians in rand_vec_spread_deg
1 parent f5b6228 commit 8ae1808

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

arcade/math.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def rand_vec_spread_deg(angle: float, half_angle_spread: float, length: float) -
289289
length (float): The length of the vector
290290
"""
291291
a = rand_angle_spread_deg(angle, half_angle_spread)
292-
vel = Vec2.from_polar(a, length)
292+
vel = Vec2.from_polar(math.radians(a), length)
293293
return vel.x, vel.y
294294

295295

@@ -421,7 +421,7 @@ def rotate_around_point(source: Point2, target: Point2, angle: float):
421421
dx = diff_x * c - diff_y * s
422422
dy = diff_x * s + diff_y * c
423423

424-
return target[0] + dx, target[1] + dy
424+
return source[0] + dx, source[1] + dy
425425

426426

427427
def get_angle_degrees(x1: float, y1: float, x2: float, y2: float) -> float:
@@ -451,7 +451,7 @@ def get_angle_radians(x1: float, y1: float, x2: float, y2: float) -> float:
451451
"""
452452
x_diff = x2 - x1
453453
y_diff = y2 - y1
454-
return math.atan2(x_diff, y_diff)
454+
return math.atan2(y_diff, x_diff)
455455

456456

457457
def quaternion_rotation(axis: Point3, vector: Point3, angle: float) -> tuple[float, float, float]:

0 commit comments

Comments
 (0)