title: Hexagonal Grids, how do you find which hexagon a point is in?
body: <p>I have a map made up of rows and columns of hexagons<img src="https://i.stack.imgur.com/t09RY.png" alt="" /></p>
  <p>This isn't an actual image of the hex-map I am using, but uses the same size and shape hexagons</p>
  <p>I need to be able to tell which one the mouse is over when the user clicks,</p>
  <p>Each Hexagon is represented by an instance of a &quot;Tile&quot; class, however this doesn't hold any location specific data, or even a polygon, so basically the only way to tell where a particular hexagon is, is to know it's position in the 2D array.</p>
  <p>I have used a square grid before, and it was relatively easy to figure out which square was selected, because pixels are also square,</p>
  <pre><code>// Example where each square is 10 by 10 pixels:
  private void getClickedSquare(MouseEvent me)
  {
      int mouseX = me.getX(); // e.g. 25
      int mouseY = me.getY(); // e.g. 70
  
      int squareX = (int)(mouseX / 10); // in this case 2
      int squareY = (int)(mouseY / 10); // in this case 7
  
      // Then to access the tile I would do
      map.squares[squareX][squareY].whatever();
  }
  </code></pre>
  <p>But I'm not even sure where to start with Hexagons, does anyone have any experience?</p>
  <p>I cannot use polygons (Java), as when I get onto moving the map around on screen, and increasing it's size I'll run into problems with updating vast amounts of polygons each frame. Although then I could just check to see if a point is included in any of the map's tile's polygons!</p>
  <p>At the moment the hexagons displayed are just BufferedImages.</p>
  <p>If you want to know any more information please ask,
  Thanks for your time :D</p>