Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. destroyingAsteroids.sort((c1, c2) -> {
  2. if (c1.x == stationCoords.x && c1.y<stationCoords.y && c2.y>=stationCoords.y) return -1;
  3. if (c2.x == stationCoords.x && c2.y<stationCoords.y && c1.y>=stationCoords.y) return 1;
  4. if (c1.x > stationCoords.x && c2.x < stationCoords.x) return -1;
  5. if (c2.x > stationCoords.x && c1.x < stationCoords.x) return 1;
  6. var angle1 = Math.atan2(c1.x - stationCoords.x, c1.y - stationCoords.y);
  7. var angle2 = Math.atan2(c2.x - stationCoords.x, c2.y - stationCoords.y);
  8.  
  9. return Double.compare(angle1, angle2);
  10. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement