scaleGrid icon indicating copy to clipboard operation
scaleGrid copied to clipboard

Improvement: Accept multiple drawings of squares and average them

Open trev33b opened this issue 4 years ago • 2 comments

I was working on a map that was hand-drawn. While the spacing of the rows/columns was mostly consistent, it wasn't perfect. This makes it really hard to make the map grid size the best/average size.

As a suggestion, create a mode that allows the user to drag out multiple squares in arbitrary locations on the map. Once the user is done creating squares, examine the size of the squares and the distance between the squares to find the best (average) possible grid size. Assuming a mostly regular grid, the distance between squares should be a multiple of the square size (in both the x and y directions).

You can use the distance between squares as another datapoint to help calculate a good average size. For example, if I drew a square from 100,100 to 120,120 and another at 198, 201 to 217, 220. You should be able to figure out that the average square size is close to 20 pixels. Further more, you should be able to figure out that the distance between the squares is roughly 100 pixels and that 100/20 = 5 (roughly). Let's say, for example that instead of 5, you get 5.1. You know that the map should be regular, so the next step is to round the 5.1 to the nearest whole number (5) and then feed that back into the distance between squares (100/5) = 20 to calculate the average size of squares between the first and 2nd square. That average should be more accurate than the original average of the squares.

Hopefully you understand my example, I know numbers I chose may not be the best because I pulled them out of thin air.

Lastly, if you allow the user to enter multiple (more than 2 squares), then the calculation should get more accurate as more squares are entered. If the user created squares somewhere near the 4 corners of the map (roughly) and maybe a few middle squares for large maps, then you should end up with a pretty accurate grid.

trev33b avatar Aug 27 '20 05:08 trev33b

Bonus points: If you get this working and combine it with the ability to allow the user to enter the number of rows/columns the square will represent (see my other suggestion in Issue #15), then someone could use this same technique to help convert a map from one square size (like 10') to another (like 5').

trev33b avatar Aug 27 '20 06:08 trev33b

In case it's helpful, the map I was using that had this problem was from the Danger at Dunwater map (provided by WotC's D&D Ghosts of Saltmarsh adventure). This map was likely made a long time ago without the aid of computers.

trev33b avatar Aug 27 '20 06:08 trev33b