Jump to content
  • Advertisement
Sign in to follow this  
Johannes1991

Square/Circle Overlap test

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been trying to calculate if a circle is inside a square. For now I can only check if the circles center is in the square.

Thanx in Advance :)

Share this post


Link to post
Share on other sites
Advertisement
Break the square into line segments. Check if each line segment intersects the circle if not then circle is inside if so then circle isn't inside(given what you already have ).

Share this post


Link to post
Share on other sites
Quote:
Original post by stonemetal
Break the square into line segments. Check if each line segment intersects the circle if not then circle is inside if so then circle isn't inside(given what you already have ).
Although you can do it this way, it shouldn't be necessary to perform per-edge tests, I don't think. You should be able to simply perform a point containment test using a square that's been 'shrunk' by the circle radius. (IINM.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!