Algorithm to determine all hexagons within an arc from a starting hexagon

I have a game engine which handles hexagon based war games and things like LOS, etc, for both flat and tip up hexes. A particular game I'm implementing at the moment, Band of Brothers, has facing for vehicles and, optionally, for infantry.

I've searched the web and have not found any algorithm to handle determining the hexagons that fall within an arc expanding out from a hexagon. Here are some pictures to describe what I'm talking about:

I represent the hexagon locations as offset coordinates, and have the values for all the dimensions of each hexagon and the endpoints of the vertices and center in relation to the overall map stored as doubles. I also convert to cube coordinates for determining distance.

Just looking for ideas or pointers on how I might determine these hexagons.

EDIT: I do not have a rep > 10 so I can't add a picture of offset coordinates. There is a good one here on gamedev though. Here's an ASCII art representation of it. The numbers will be a little different depending on which row is indented:

0,0   1,0   2,0   3,0   4,0
0,1   1.1   2.1   3.1
0,2   1,2   2,2   3,2   4,2

• Part of the problem with your searching may be that that shape is a hexagon not a hex. When you said hex I initially thought you ment the hexadecimal number system (that is sometimes called hex) – Richard Tingle Apr 19 '17 at 19:02
• This depends on how you index your hexes, and what kind of arcs you want to support. – Peter Apr 19 '17 at 20:36
• If the maximum distance from the center of the arc is a small number of hexes, you could try out a "dumb" implementation. Checking all of the hexes within a short range (say, 5 tiles away or less) should be quick. I'm assuming here that you don't need to do this 1000s of times per frame...though that still may be fast enough. – Victor T. Apr 19 '17 at 23:46
• Thanks for responding everyone. I index them in an array but the are stored with offset coordinates. Going by the first picture, I need to arc out 120 degrees and 60 degrees. The 2nd picture, seems like a 180 degree arc jetting out from the upper 2 vertices. And yes, I could just do that kind of approach. I would be done once and be cached it so there would just be that one time penalty. I do the same with LOS, I tuck away LOS from every hex to every other hex and tuck away the hexes between the 2 points to check for dynamic entities (like moving troops, smoke, etc). – Brian Sturk Apr 20 '17 at 14:02
• Not sure if this will help but its worth looking into: redblobgames.com/grids/hexagons – user16195 Apr 20 '17 at 22:29