Bring this test page up and click "Show Hex" in the upper right to understand what I'm saying here:

**PLEASE USE Internet Explorer!**I just realized there's a problem with the mouseover using Chrome.

http://baronsofthega...om/hextest.aspx

I have a large galaxy on a hexagon map and this map is subdivided by larger hexagons on a scale of 1 to 25. The big hexes are 25 "Smaller" hexes across. From the center of one subdivision to the center of another is 25 hexes. It is also subdivided 5 times as you zoom out to view the entire galaxy. I call these big subdivisions "Quadrants" then "Zones" etc down to the actual Galactic Grid coordinates that something is on.

It looks like this as you zoom in down to New York on Earth:

http://baronsofthega...barons5zoom.gif

As you zoom in you are clicking on a coordinate in the big hex where the center of the hex is 17:17. As you click down to New York in the screenshot, it has a a set of coordinates that look like this: 17:24, 17:17, 17:17, 17:17, 18:12, 11:14 and New York is on galactic coordinate -19:-68359247 from center of the universe. I translate the coordinates to actual named objects if they exists in the navbar. My hexagon map coordinate system is laid out like this:

http://baronsofthega...oordpattern.gif

I can figure out the galactic coordinate by multiplying the other coordinates offset by 17:17 and added to (25 ^ <the zoom level>). Which is to say, for every top level "Quadrant" hex you are offset by, your galactic coordinate moves by about 9765625 (25 to the 5th power) and then for every second level "Zone" you are offset from 17:17 by, you are at an additional 390625 (25 to the 4th power) hexes in that direction etc.

Its done in the database where you pass in all the coordinates and it gives you the galactic coordinate. The SQL code looks something like this:

Declare @intGalacticHex_X int

SET @intGalacticHex_X = 0

SET @intGalacticHex_X = @intGalacticHex_X + ((17 - @Quad_X) * (POWER(25,5)))

SET @intGalacticHex_X = @intGalacticHex_X + ((17 - @Zone_X) * (POWER(25,4)))

SET @intGalacticHex_X = @intGalacticHex_X + ((17 - @Sector_X) * (POWER(25,3)))

SET @intGalacticHex_X = @intGalacticHex_X + ((17 - @System_X) * (POWER(25,2)))

SET @intGalacticHex_X = @intGalacticHex_X + ((17 - @Hex_X) * (25))

SET @intGalacticHex_X = @intGalacticHex_X + ((17 - @Grid_X))

-- Return the result of the function

RETURN @intGalacticHex_X

**SO HERE'S MY PROBLEM**

While I can figure out your galactic coordinate based on all the upper tier coordinates you've provided, I haven't figured out how to the reverse it correctly. As in, If I give you a galactic coordinate, say New York on -19:-68359247 , I need to return the Quadrant, Zone, Sector, System, Hex and Grid Coordinates back (i.e. 17:24, 17:17, 17:17, 17:17, 18:12, 11:14)

It's a similar problem to the way you can translate pixel coordinates of the mouse to Hexagon coordinates, which I've been able to figure out with a lot of help, but I can't figure this one out as I can't find anyone who has an example.

Take the following graphic, which is kind of a zoom in of earth near Jupiter from the other screenshot, to to see how it is not straightforward:

http://baronsofthega...rthjupiter5.gif

Much like pixel to hexagon coordinates solutions, you probably need to break up the hex and do a different algorithm depending which part of the bigger hex it is in. New york is a bad example because its towards the center, but a spot towards the tips on the left or right is more difficult to figure out. As its vertical coordinate changes it runs across one subdivision for a few hexes and then the next for several more hexes.

Also, there is a "border" between hexes where the two bigger hexes technically share half of the hex. If you are on that border (There will be ships flying around) I need to have that ship resolve its coordinates in a consistent way, most likely dropping a fraction and having them be in the subdivision to the upper left. As long as they resolve consistently it's irrelevant which way they go but they cannot be in two subdivision hexes at the same time.

I tried a few different ways of resolving this but I can't wrap my head around it. The irony is that I can determine your galactic coordinate given all the other coordinates but I couldn't reverse it. I feel the simplest solution is to simply REVERSE the process I used to get your galactic coordinate using algebra but again, I tried and failed. I can figure out your X coordinate by using the powers of 25 and adding them together but to reverse it and get back all the other coordinates, I think I need to know your Y coordinate also.

I've tried some stuff using MOD 25 to try to figure out which subdivision you are on but again, I think I need to use both coordinates or try to figure out your "offset" first or something.

You can also zoom to the center of the galaxy to bring the galactic coordinates down to a manageable size and understand the coordinate system I'm using better. Start in the Milky Way and choose the center hex 17:17 all the way down and you should be at galactic 0:0. then zoom out and move around a bit to see how the coordinate system works.