Rhys Goldstein has had one more excellent article published in Towards Data Science. This is the third - and he says final, I hope he’s wrong - article in the series.
Here they are, along with my accompanying posts:
- A Short and Direct Walk with Pascal’s Triangle
- A Quick and Clear Look at Grid-Based Visibility
- A Sharp and Solid Outline of 3D Grid Neighborhoods
- This post. :-)
In this latest installment, Rhys explores one particular aspect of what it means to go from a 2D pathfinding environment to one focused on 3D.
When looking at adjacent positions within a 2D grid, it’s possible to have 4-, 6-, 8-, 12- and 16-neighborhoods:
These map very differently to 3D, where we end up with 6-, 18-, 26-, 50-, and 74-neighborhoods!
It seems no-one had previously connected the 2D neighborhoods with their 3D equivalents, which was Rhys’s goal from this article.
Here they are, one-by-one. Let’s start with the rectangular neighborhoods.
A 2D 4-neighborhood is a section of the 3D 6-neighborhood:
A 2D 8-neighborhood is a section of the 3D 26-neighborhood:
A 2D 16-neighborhood is a section of the 3D 74-neighborhood:
Now for the triangular neighborhoods.
A 2D 6-neighborhood is a section of the 3D 18-neighborhood:
A 2D 12-neighborhood is a section of the 3D 50-neighborhood:
Things get much more complex beyond these first 5, of course. I really don't blame Rhys for stopping there. :-)
If you're interested in seeing some code that uses these various 3D neighborhoods to solve a visibility problem, be sure to check out the Python source in Rhys's fascinating post.