Live data from Hacker News

Hexagonal Grids (2013)

redblobgames.com

21–30 of 47 posts

Re: Hexagonal Grids (2013)

#21
post #8

A surprise to see my page on HN! For those of you curious about the tech: Diagrams are in SVG. Canvas would be faster but SVG is easier for me to work with, especially for attaching mouse events to each hexagon. It also automatically scales to high dpi displays. With SVG and HTML accessed the same way, I can use the same code for updating text/samples as I do for updating diagrams. This includes interpolating values…

Your guide is the first thing I open in my browser every time I need to code an algorithm in a hexagonal space.

Thanks a lot for the amazing work!

Re: Hexagonal Grids (2013)

#22
post #8

A surprise to see my page on HN! For those of you curious about the tech: Diagrams are in SVG. Canvas would be faster but SVG is easier for me to work with, especially for attaching mouse events to each hexagon. It also automatically scales to high dpi displays. With SVG and HTML accessed the same way, I can use the same code for updating text/samples as I do for updating diagrams. This includes interpolating values…

I used your site to implement A* as a learning exercise, and I learned a lot from it. Thanks!

Re: Hexagonal Grids (2013)

#23
post #8

A surprise to see my page on HN! For those of you curious about the tech: Diagrams are in SVG. Canvas would be faster but SVG is easier for me to work with, especially for attaching mouse events to each hexagon. It also automatically scales to high dpi displays. With SVG and HTML accessed the same way, I can use the same code for updating text/samples as I do for updating diagrams. This includes interpolating values…

Have used the page maby times. It's brilliant, and perfectly explains. Thanks a lot!

Re: Hexagonal Grids (2013)

#24
post #8

A surprise to see my page on HN! For those of you curious about the tech: Diagrams are in SVG. Canvas would be faster but SVG is easier for me to work with, especially for attaching mouse events to each hexagon. It also automatically scales to high dpi displays. With SVG and HTML accessed the same way, I can use the same code for updating text/samples as I do for updating diagrams. This includes interpolating values…

> . I use cheesy pre-rendering for this: "$(CHROME) --headless --disable-gpu --dump-dom". It means more bytes :( but having all the HTML/SVG load at once is better for linking to a section, hitting the back button, etc. You don't lose the scroll position.

this is an excellent tip! thanks for the awesome technique.

Re: Hexagonal Grids (2013)

#26
This article made me realize that my NIH collision algorithm I implemented the other day[0] is a dead end.

I wanted to put obejcts into bins so that pairs which are unlikely to collide are not checked.

Square bins are nice, but an object can potentially be in four of them at a time.

Hexagonal bins on the other hand reduce that number to three - great, but assignment is not as obvious.

If you look at the hex pattern the centers form a skewed grid - an appropriate affine transform should deal with that.

Does it help? Kinda. Coordinates in "hex space" are weird and now I see why - I'm using the wrong coordinate system to begin with.

[0] Making a game after-hours - the real project here is escaping from the immensely pragmatic world of writing software for money.

Re: Hexagonal Grids (2013)

#28
post #16

There's also square version of hexagonal map. It is made of squares, but every second row (or column) is moved by half a tile. Like bricks in a wall or tiles in pavement. It doesn't look nearly so neat if the tile borders are visible, but when they aren't it doesn't make a difference as long as you draw tile backgrounds right. And it's easier to calculate on which tile you are, but it still keeps some of the benefits…

That's the first coordinate system described on the page, offset coordinates.

Re: Hexagonal Grids (2013)

#30
post #29

Very cool! If you like hexagons, and boy do I like hexagons, I recommend also checking out Uber’s Hexagonal Hierarchical Spatial Index https://eng.uber.com/h3/

this uber-h3 has been public for a while, and it brings mixed reaction for me -- it seems like Uber wanted to 'invent' something really cool, as in, the showing off part is every bit as important, or more, than the tech. The reason to point that out is, spatial indexing is one of seriously studied topics in academic geometry. Yes, the classical papers can be a bit much, but there is a reason why they are so -- it really does benefit from that kind of attention.

If Uber needed a different kind of spatially indexed filter and search, then some system that is adaptive to data density would seem like the performant thing to build. Nested-hexagon space is certainly fun, but real car data is distributed in certain ways, that are not rectangle and also not hexagon.

Post reply on HN