Sign in to follow this  
Nairou

List of grid points within radius of point

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
[url="http://en.wikipedia.org/wiki/Midpoint_circle_algorithm"]The midpoint circle algorithm[/url] 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.

Share this post


Link to post
Share on other sites
[quote name='alvaro' timestamp='1305567161' post='4811538']
[url="http://en.wikipedia.org/wiki/Midpoint_circle_algorithm"]The midpoint circle algorithm[/url] 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.
[/quote]

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this