Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Hex (H) Calculations to fit hexmap image, Again

1603479310

Edited 1603479896
Back at it again, feel like I'm figuring stuff out and maybe somebody will actually answer my question this time instead of saying "just fudge it manually until it is close enough". Background For Those Who Don't Know In case anyone reading this doesn't know, roll20's hexes don't respect the number of cells you pick. Hex (H) (which correctly picks horizontally oriented hexes, that is, each hex's largest dimension spans horizontally), if it were correctly implemented would given you as many hexes vertically as you specify in the Height on a page. It does not. It has been promised that this would be fixed for over 7 years but it hasn't been. It is also the case that the math that specifies the hexes for Roll20 does not draw regular hexagons (or at least, whatever hexagons that are standard for hexmaps and hexmapping software). More on that later. What I've been able to figure out to align a hexmap image in roll20, but using math instead of fiddling with it by eye. Thanks to various hex-related APIs from the community, I've found measurements for roll20's hex, I'm not sure how these numbers were arrived by the people using them, but here they ar const UNIT_PIXELS_SIDE_H_DIST = 79.688789983504; const UNIT_PIXELS_DIAG_H_DIST = 80.185196764184; const UNIT_PIXELS_DIAG_H_DX   = 69.585127490377; const UNIT_PIXELS_DIAG_H_DY   = 39.844394991752; const UNIT_PIXELS_H_START_X   = 94/2; const UNIT_PIXELS_H_START_Y   = 81/2; Doing 70 (the standard roll20 cell height) divided by  UNIT_PIXELS_SIDE_H_DIST, I get  0.87841715270730512222684903731446. Roll20 only allows so much precision, so in the Cell Height spot in my page it becomes 0.8784171527073051. Precise enough for our purposes. Doing this now means that whatever number I put in the Page Height, the resultant grid used by Roll20 lines up with my grid of that many hexes tall. Halfway there! Well, sort of. The map I'm measuring is 90 tall. I am measuring 89 edge to edge, snapped. The last cell row isn't quite made... but it's close enough, maybe I need a more accurate or precise Cell Height value to get it? In any case, it is very close enough for me, as it's one cell height I can use regardless of map size. Where I'm Stuck Now I'm very happy to have gotten the height squared away, but unfortunately, it's not the end. This is how I learned the Roll20 hexes, in addition to having arcane math GMs don't get to see and have to reverse engineer to actually get them to obey "Page Height", also aren't drawn dimensionally correct, at least they use different ratios than every other map maker that all seem to line up with each other and old hex maps. My hexmap is square shaped, so I have set my page to be the same height as width, since the map is. Unfortunately, there is some distortion horizontally, and there isn't a "cell width" setting for us to mess with... so the only option is to mess with page width by, in my case, finding a multiplier to multiply the height by to find the width I need to set. (and then I would need to set the image width to match by doing a manual resize matching the page dimensions, just using the same numbers). So far in my messing around with ratios, I've determined it should be between 1.0062293175838503611720443434753 and 1.0111111111111111111111111111111 I clearly don't know what I'm doing at this point, because the numbers I care about seem to still be obscured or my decade-unused geometry knowledge isn't helping me. So, any idea what ratio I should be multiplying my page (and map image) widths by?
Based on measuring edge to edge, I'm getting about 77-78 hexes horizontally. Is there an api to give me the exact hex measurement of the width page, since I can't accurately measure it with the measuring tool? Based on the dimensions of my map image and a hexagon calculator, the target number I need is approximately 77.942322681215900233826968043648. If I can figure out what I actually have on the map right now, I should be able to find the ratio between that and my target number and use that in my page/image width in roll20.
1603481416
David M.
Pro
API Scripter
Interesting timing. I was just helping out someone else , but they were using Hex (V) coords. Along the way, I did some tests with Hex (H) to try to understand what the heck was going on. I created a hex grid map (cell width 1) and placed a token in four hex locations (center snapped to hex center) starting at the top left of the map (full hexes only), then used an api script to return the xy coords of the token. Here's what I got for the Hex (H) test, in case it helps you. Coords are at the center of the hex. Hex   X-coord   Y-coord (0,0)   46.4851274903778   39.8443949917523 (1,0)   116.0702549807550   79.6887899835046 (0,1)   46.4851274903778   119.5331849752560 (1,1)   116.0702549807550   159.3775799670090 (0,0) to (1,0) x spacing= 69.5851274903772 (0,0) to (0,1) y spacing= 79.6887899835037
MY GOD, I DID IT I've done it. I've found the magic number, and I used geometry to do it. So the problem with roll20's hexes (at least the Hex (H) ones), is that they are too short (or too wide, if you prefer). I won't bore you with the math of how I worked it out, but there's the "final" answer for people wanting to align hex maps The Final Answer? If you are using Hex (H), and a square map, set the page height to to the number of hexes, vertically. Set the width to that number multiplied by 1.0082976746938481461036010506722. Set the cell height multiplier to 0.87841715270730512222684903731446. What remains I have no maps I used or have interest in making that are Hex (V), I'm not sure how helpful this would be to those who are, but I'd be willing to help anyone figure it out now that I've done it here. I feel ashamed of how long it took me to recall high school math and problem construction (it's so poorly taught in the USA, I was an all A student in math too!), but I did it. Only thing that would make this better was if the cell height would allow, at least at my map size, the last row to have full cells. Maybe I'll hammer away at that later, for now I will bask in the afterglow of a problem solved and a ton of manual work saved from later.
David M. said: Interesting timing.  Especially as I was just typing my mania filled last post :) I didn't see yours but I'm glad you shared!
Those api script numbers are very close to the ones I pulled from&nbsp; <a href="https://github.com/Roll20/roll20-api-scripts/blob/master/Hexploration/1.3/Hexploration.js" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/blob/master/Hexploration/1.3/Hexploration.js</a> Your y distance is more precise but even using that to find the cell height to use, the last row just barely doesn't get made a usable set of hexes. That's okay in my case, since at least the hex borders are all lined up all throughout the map with the image, and I will be having a 1 hex border around the map as "Move to Map X" zones :).