hexagonal_pathfinding_astar icon indicating copy to clipboard operation
hexagonal_pathfinding_astar copied to clipboard

Support spiral coordinates

Open virtualritz opened this issue 3 years ago • 8 comments
trafficstars

See the hex-spiral crate.

Stack Exchange

virtualritz avatar May 04 '22 23:05 virtualritz

Hey, thanks for the issue, it looks very interesting managing the coordinate conversion and neighbour hex discovery. I'll dig into it over the weekend and think about what can be done

BlondeBurrito avatar May 06 '22 14:05 BlondeBurrito

Awesome.

I think the original idea is from Paul Bourke. He calls it a Spiral Honeycomb Mosaic (SHM).

See his Tiling on The Plane page. Scroll down to the section titled Hexagonal Lattice (contains links to source code with coordinate conversions).

virtualritz avatar May 06 '22 16:05 virtualritz

Just to let you know the next feature version will have a form of SHM, I don't think it's feasible to have "spikey" spirals so there must be a set number of rings around the origin. Something like if a giant letter P was made of hexagons I can't think of way to safe guard the bottom sticking out in neighbour discovery, so the implementation will be very similar to axial/cubic geometry where it's a circular grid. Once I push it up I'll tag you on the PR to see if it's what you expect if that's ok?

Once that makes 1.1.0 I'll very shortly after be releasing 2.0.0 to handle an edge case across all the coordinate systems which does mean the overall return type will become an Option<Vec<(i32, i32)>> rather than the current Vec<(i32, i32)> where None means there's no path based on #12. Just as an FYI in case you're wanting to use this for something

BlondeBurrito avatar May 19 '22 22:05 BlondeBurrito

Very cool! Let me know when there is something in the repo to test. :)

virtualritz avatar May 23 '22 13:05 virtualritz

I think the original idea is from Paul Bourke. He calls it a Spiral Honeycomb Mosaic (SHM).

For the record, I came up with the spiral coordinates in hex-spiral without any existing influences (though it's quite simple, so it's likely to have existed as a concept already), and the coordinates in Spiral Honeycomb Mosaic seem to work differently at first glance.

ljedrz avatar May 23 '22 14:05 ljedrz

I think the original idea is from Paul Bourke. He calls it a Spiral Honeycomb Mosaic (SHM).

For the record, I came up with the spiral coordinates in hex-spiral without any existing influences (though it's quite simple, so it's likely to have existed as a concept already), and the coordinates in Spiral Honeycomb Mosaic seem to work differently at first glance.

They do indeed. My bad. And since there is no Rust crate that supports SHM at all I would ask @BlondeBurrito to use hex-spiral as a testbed for the spiral a-star pathfinding being added to this crate.

virtualritz avatar May 23 '22 16:05 virtualritz

Just to let you know the next feature version will have a form of SHM, [...]

Is there any update on this or code that can be tested?

virtualritz avatar Jan 28 '23 18:01 virtualritz

Hey, please accept my apologies, in truth I forgot about this - I reached a point of burnout with work and haven't had the energy to hobby code very much.

I've tidied up what I did and raised PR #15 which introduces Spiral Hex based coordinates in the style of @ljedrz. Tests are passing. The coordinate style in the works of Paul Bourke making use of clusters of hexagons with a base7 numbering system proved too hard really but hopefully this is still useful. Most of it boils down to converting Spiral Hex coords into Cubic coords as they're a bit easier to work with.

Let me know what you think and once merged I'll tag it and publish a new crate version

BlondeBurrito avatar Jan 31 '23 01:01 BlondeBurrito