Jump to content
  • Advertisement
Sign in to follow this  
nprz

Determining All Points/Pixels within a circle

This topic is 4799 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 am working on making a strategy game similar to Worms and I need to find all the points that lie within a circle of a certain radius. This is for changing the map after an explosion. Does anyone have a suggestion of how to do this?

Share this post


Link to post
Share on other sites
Advertisement
All points that are within the radius of the circle.

Basically:

dx = centerOfCircle.x - point.x;
dy = centerOfCircle.y - point.y;
return dx*dx + dy+dy < radius * radius;

EDIT:

If true, then the point is inside the circle. If false then point is outside.

Share this post


Link to post
Share on other sites
I guess I could use that and put it within a for loop that is a box of the radius.
Thanks, that should be efficient enough.

-edit- Worked great.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!