# List of grid points within radius of point

## Recommended Posts

Nairou    430
(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 on other sites
alvaro    21263
[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 on other sites
Nairou    430
[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!

## 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