+ 2

Hello guys, plz suggest me a technique to find collisions between circles

I want to add inter circle collisions in my code https://code.sololearn.com/WoOo26XYznFf/?ref=app

4th Sep 2021, 1:24 PM
CodeSmith
CodeSmith - avatar
4 ответов
+ 3
xfirstcircle - xsecondcircle >= 0 and xfirstcircle - xsecondcircle <= r*2 and yfirstcircle - ysecondcircle <= r*2 and yfirstcircle - ysecondcircle >= 0 and x is the x position of the circle y is the y position of the circle r*2 = diameter of the circle
4th Sep 2021, 1:39 PM
Vitanonimato
Vitanonimato - avatar
+ 3
xfirstcircle - xsecondcircle >= -r and xfirstcircle - xsecondcircle <= r and yfirstcircle - ysecondcircle <= r and yfirstcircle - ysecondcircle >= -r and Maybe this one
4th Sep 2021, 3:42 PM
Vitanonimato
Vitanonimato - avatar
+ 2
Vitanonimato thanks for answering bro, I realised circle collision is easier than rect collision. we just have to check if distance between center of both circle are less than sum of their radius. https://code.sololearn.com/Wx2bObC3nXNw/?ref=app
4th Sep 2021, 6:26 PM
CodeSmith
CodeSmith - avatar
0
Vitanonimato Thanks, I have tried it before. It is only giving rectsngle collision.
4th Sep 2021, 3:24 PM
CodeSmith
CodeSmith - avatar