Quantcast
Channel: Ball to Ball Collision - Detection and Handling - Stack Overflow
Viewing all articles
Browse latest Browse all 16

Answer by Estid Felipe Lozano Reyes for Ball to Ball Collision - Detection and Handling

$
0
0

Improving the solution to detect circle with circle collision detection given within the question:

float dx = circle1.x - circle2.x,      dy = circle1.y - circle2.y,       r = circle1.r + circle2.r;return (dx * dx + dy * dy <= r * r);

It avoids the unnecessary "if with two returns" and the use of more variables than necessary.


Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>