calculating 2d Circle collesion

This topic is 4122 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

hi, I am creating a game i dont know how could i achieve the below targets. Overview: There is one big circle exist in the middle of the screen, that circle needs to be covered by 5 small circles. If all small circle accurately cover the whole BIG circle and doesnt let any part naked then user will get high score. If he couldnt cover the whole BIG circle with small circles then player will get low score. Problem: 1)I dont know by which method i can calculate that how much part of the BIG circle is still visible. 2) I need to do 2d graphic techniew to calculate the areas of all circles. 3) Any formula or site for this kind of information??? please kindly guide me what to do?? Regards

Share on other sites
Well the task is to get the amount of pixels that the small circles are overlapping the larger circle.

So you first need to calculate how many pixels are in the big circle. This will give you a target for the amount of pixels that are possible to overlap.

Then you can modify some pixel perfect collision detection code and count the number of pixels that the small circles overlap with the larger circle.

Then you also need to take into account overlap between two small circles and exclude that from your final calculation.

To do that you would need to keep track of which overlaps have already been found so that you don't count the overlaps twice. Either that or you could only subtract half the amount that needs to be subtracted and just assume that the overlap will be detected twice.

Share on other sites
dx = circle1.x - circle2.x;
dy = circle1.y - circle2.y;
dist_squared = dx * dx + dy * dy;
collision();
else
no_collision();

The above is for collision between two circles, to make sure the smaller circles are in the bigger circle (if I understand you correctly). You can modify the above to make sure the entire circle is contained in another circle, if you wish.

Then, it's a matter of calculating the area of each of the circles and substracting.

1. 1
2. 2
Rutin
19
3. 3
4. 4
frob
13
5. 5

• 9
• 15
• 10
• 9
• 17
• Forum Statistics

• Total Topics
632602
• Total Posts
3007364

×