Questions tagged [hexagonal-tiles]

Tessellating tiles for use as 2d-histogram bins, game boards, etc.

Hexagonal tiles are tessellating hexagons placed adjacently to each other.

The use of this tag is fairly broad, encompassing statistics, computer science and game design.

234 questions
75
votes
14 answers

Covering Earth with Hexagonal Map Tiles

Many strategy games use hexagonal tiles. One of the main advantages is that the distance between the center of any tile and all its neighboring tiles is the same. I was wondering if anyone has any thoughts on marrying a hexagonal tile system with…
carrier
  • 32,209
  • 23
  • 76
  • 99
53
votes
1 answer

Hexagonal Grid Coordinates To Pixel Coordinates

I am working with a hexagonal grid. I have chosen to use this coordinate system because it is quite elegant. This question talks about generating the coordinates themselves, and is quite useful. My issue now is in converting these coordinates to…
captncraig
  • 22,118
  • 17
  • 108
  • 151
36
votes
9 answers

Hexagonal Grids, how do you find which hexagon a point is in?

I have a map made up of rows and columns of hexagons This isn't an actual image of the hex-map I am using, but uses the same size and shape hexagons I need to be able to tell which one the mouse is over when the user clicks, Each Hexagon is…
Troyseph
  • 4,960
  • 3
  • 38
  • 61
31
votes
3 answers

Mathematically producing sphere-shaped hexagonal grid

I am trying to create a shape similar to this, hexagons with 12 pentagons, at an arbitrary size. (Image Source) The only thing is, I have absolutely no idea what kind of code would be needed to generate it! The goal is to be able to take a point in…
31
votes
5 answers

Generating triangular/hexagonal coordinates (xyz)

I'm trying to come up with an iterative function that generates xyz coordinates for a hexagonal grid. With a starting hex position (say 0,0,0 for simplicity), I want to calculate the coordinates for each successive "ring" of hexagons, as illustrated…
John Schulze
  • 2,198
  • 3
  • 20
  • 22
23
votes
6 answers

Manhattan Distance between tiles in a hexagonal grid

For a square grid the euclidean distance between tile A and B is: distance = sqrt(sqr(x1-x2)) + sqr(y1-y2)) For an actor constrained to move along a square grid, the Manhattan Distance is a better measure of actual distance we must…
Coyod
  • 2,656
  • 2
  • 18
  • 13
21
votes
5 answers

JavaScript Point Collision with Regular Hexagon

I'm making an HTML5 canvas hexagon grid based system and I need to be able to detect what hexagonal tile in a grid has been clicked when the canvas is clicked. Several hours of searching and trying my own methods led to nothing, and porting…
Oliver
  • 1,576
  • 1
  • 17
  • 31
20
votes
4 answers

Setting hex bins in ggplot2 to same size

I'm trying to make a hexbin representation of data in several categories. The problem is, facetting these bins seems to make all of them different sizes. set.seed(1) #Create data bindata <- data.frame(x=rnorm(100), y=rnorm(100)) fac_probs <-…
sebastian-c
  • 15,057
  • 3
  • 47
  • 93
18
votes
3 answers

Algorithm to generate a hexagonal grid with coordinate system

I am trying to roll up 19 lines of code into a single for loop, but I am feeling a bit stumped. The reason I ask, is because I want the grid to be other sizes instead of 5. In Main::drawHexGridAdvanced(), I am trying to deduce the similarities…
Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
17
votes
11 answers

Calculating distance on a hexagon grid

What I am trying to do is find how many hexagons are in between two points on a hex grid. I have tried searching online for a formula but I have not been able to find one that matches the type of hex grid I am using. The hex grid is laid out like…
DeathorGlory9
  • 299
  • 1
  • 2
  • 8
16
votes
2 answers

Hexagonal tiles and finding their adjacent neighbours

I'm developing a simple 2D board game using hexagonal tile maps, I've read several articles (including the gamedev one's, which are linked every time there's a question on hexagonal tiles) on how to draw hexes on the screen and how to manage the…
Luke B.
  • 1,258
  • 1
  • 17
  • 28
14
votes
7 answers

Distance between 2 hexagons on hexagon grid

I have a hexagon grid: with template type coordinates T. How I can calculate distance between two hexagons? For example: dist((3,3), (5,5)) = 3 dist((1,2), (1,4)) = 2
zodiac
  • 353
  • 3
  • 18
14
votes
2 answers

Creating grid of hexagons

I have to do a "grid" like this: Harmonic table I'm trying to create a ListView with ItemsSource="List" where every odd note in the list is moved on the bottom... Is the ListView the right control? How can I draw an exact hexagon with faces…
Mauro Destro
  • 746
  • 12
  • 34
12
votes
2 answers

ggplot2 multiple stat_binhex() plots with different color gradients in one image

I'd like to use ggplot2's stat_binhex() to simultaneously plot two independent variables on the same chart, each with its own color gradient using scale_colour_gradientn(). If we disregard the fact that the x-axis units do not match, a reproducible…
metasequoia
  • 7,014
  • 5
  • 41
  • 54
11
votes
2 answers

Finding adjacent neighbors on a hexagonal grid

EDIT: Wrapped the example map in a code block so the formatting is correct. Ok, I'm trying to write an extremely simple A* algorithm over a hexagonal grid. I understand, and can do the A* portion. In fact, my A* works for square grids. What I can't…
Jonathanb
  • 1,224
  • 1
  • 11
  • 16
1
2 3
15 16