Advertisement
Kostiggig

Untitled

May 2nd, 2023
1,148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. bool intersected(Ball ball) {
  2.     for (int i = 0; i < balls.size(); i++) {
  3.         double dx = balls[i].x - ball.x;
  4.         double dy = balls[i].y - ball.y;
  5.         double distance = sqrt(dx * dx + dy * dy);
  6.         if (distance < balls[i].radius + ball.radius) return true;
  7.     }
  8.     return false;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement