Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions physics/collisions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Basic implementation of the collision of two circles.
def circle_collision(
fpos: tuple[float, float, float], spos: tuple[float, float, float]
) -> bool:
# difference by XY axes
dx = fpos[0] - spos[0]
dy = fpos[1] - spos[1]

# Euclidean distance between the centers of circles
distance = pow((pow(dx, 2) + pow(dy, 2)), 0.5)

# minimum possible distance between circles, without collision
min_distance = fpos[2] + fpos[2]

# If actual distance smaller than minimal possible, cirlces collides
if distance < min_distance:
return True

return False

Check failure on line 19 in physics/collisions.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (SIM103)

physics/collisions.py:16:5: SIM103 Return the condition `distance < min_distance` directly
Loading