10
$\begingroup$

I have an image which my DM made of map for a DND game and I want to do two things.

  • Click on two points on my map, then based on the key for scaling have Mathematica tell me how far apart those points are.

  • Given a distance and a point that I click on, draw a circle about the given point that has the radius of the given distance.

enter image description here

If anyone will give me advice for how to get started on this project, I would be very grateful.

$\endgroup$

2 Answers 2

16
$\begingroup$

enter image description here

Both tasks you outlined could be fused into a single app - screenshot is above. I assume that because this is a game the corrections due to geodesic model (flat map from non-flat planet surface) do not really matter (this was not mentioned in the project description). Here is a quite simple code to get you started that you can modify and upgrade.

i = Import["https://i.stack.imgur.com/TVsMy.jpg"];

Manipulate[
    Column[{
    Style["Advantures will take you "<>
        ToString[Round[.7595 RegionMeasure[N[Line[pt]]],.01]]
        <>" miles",20,FontFamily->"Herculanum"],
    HighlightImage[i,{Thickness[.003],Dashing[.01],
        Line[pt],
        Circle[pt[[1]],EuclideanDistance@@pt[[;;2]]]},
    ImageSize->800]
    },Alignment->Center],
{{pt,{{1610,100},{2005,100}}},Locator,LocatorAutoCreate->True}]

A few things to take a note:

  • In addition to the distance between 2 points you can build a whole path and measure its length.

  • Add or remove more path points with CMD(ALT)+CLICK on Mac (Win).

  • Decreasing image size will make your app faster

  • Scaling factor in front of RegionMeasure can be adjusted to match map scale. It is done by simply running app for the firs time when in initial stage the path is equal to the map scale length (see next image below). Then adjust the scaling factor so number in the title is equal to the number on the map scale.

  • In the initial state there are only 2 points and a circle centered at 1st and passing through 2nd. Dragging locators around and see how number in the title changes effectively solves your second task. Place 1st point at a needed location and then drag 2nd to measure needed radius that is indicated in the plot title and you get the circle you need.

enter image description here

$\endgroup$
4
  • 1
    $\begingroup$ This is amazing, thank you so much. One quick question though, I don't seem to be able to add the additional points like in your first screen shoot (in using windows) $\endgroup$
    – Wombles
    Apr 8, 2019 at 21:26
  • $\begingroup$ @Wombles you are welcome :) Read docs HERE especially details section. I corrected the post - on Win it is ALT+CLICK. Thanks for noting! $\endgroup$ Apr 8, 2019 at 21:31
  • 1
    $\begingroup$ Yes, fantastic answer Vitaliy. I have often wanted to use Mathematica for my own DnD game - perhaps now I will :) $\endgroup$
    – Carl Lange
    Apr 8, 2019 at 21:36
  • $\begingroup$ Will do, i also need to download that sweet font too. $\endgroup$
    – Wombles
    Apr 8, 2019 at 21:37
3
$\begingroup$

I have some advice, but it is just that, and not a solution to your problem.

  • Decide on a geodetic model for the world you are mapping. I recommend picking one of the geodetic models of planet Earth that Mathematica recognizes.
  • Decide on what the projection from a sphere to your map grid will be.
  • Use the built-in functions GeoGridPosition and GeoPosition to transform coordinates between the grid (map) and the model (sphere).
  • Look at GeoProjectionData to learn about Mathematica knows about projections.

Note: depending on the projection you choose, a circle about a point on sphere may not appear as a circle on your map.

BTW, nice looking map.

$\endgroup$
1
  • $\begingroup$ Thank you for the advice and the starting point. $\endgroup$
    – Wombles
    Apr 8, 2019 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.