Jump to content
  • Advertisement
Sign in to follow this  
Nairou

List of grid points within radius of point

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

(Apologies if this is a trivial issue that I could search for... I did a few searches but didn't really know what to search for.)

Let's say you have a large grid (game world), and at some point on that grid you have a point of interest (say, a factory). The factory produces units, which are then deposited around the factory on the grid. The units can be placed anywhere within a circular radius of the factory. No two units can be placed at the same grid point.

My question is, is there a quick way to predetermine the coordinates of all grid points within that radius, so I can pull empty spots from a list rather than having to continually measure distances between points to see if it is within range? I know the math for drawing a circle outline, but not for gathering all of the points within that circle.

Share this post


Link to post
Share on other sites
Advertisement

The midpoint circle algorithm is the traditional method to find the grid points at the border of the region you are interested in. You should be able to modify the algorithm a bit to suit your needs.


Nice! From the algorithms on the page you linked, I think I've found a way to pull this off. Thanks!

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!