• Advertisement
Sign in to follow this  

Determining All Points/Pixels within a circle

This topic is 4711 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