lefakkomies / pynomo

Python nomographs (nomograms).
GNU General Public License v3.0
88 stars 24 forks source link

Discrete values #23

Open tunesmith opened 2 years ago

tunesmith commented 2 years ago

I just discovered this project this weekend and am curious if it might be possible to translate a react app I developed into a one-sheet nomogram. The react app is a calculator that determines a result based off of five inputs, but the problem I haven't figured out is if I can create scales with discrete values. This might mean Type 5 with jagged contour lines, but I'm having trouble getting a Type 2 working either. For example, I have a correspondence table that looks like this:

const fighterLevels = new Map<number, number>([
  [0, 21],
  [1, 20],
  [3, 18],
  [5, 16],
  [7, 14],
  [9, 12],
  [11, 10],
  [13, 8],
  [15, 6],
  [17, 4],
]);

The point is it is not smoothed - while 1 corresponds to 20, 2 should correspond to 20 as well. Then 3 should jump to 18. (For context, this is a combat skills table from old school 1st edition Dungeons & Dragons.) Other tables have wider gaps in places, so there is no true continuous pattern.

When defining the lookup function for 'function': lambda u: lookup(u), I first tried to return discrete values for each integer, but then when running python <script>.py, the process hung and never completed.

When I changed it to return something more along the lines of continuous values,

def lookup(level):
    if level < 1:
        return 21 - level
    elif 1 < level <= 2:
        return 22 - level
    elif 2 < level <= 3:
        return 21 - level
    elif 3 < level <= 4:
        return 22 - level
    elif 4 < level <= 5:
        return 21 - level
    elif 5 < level <= 6:
        return 22 - level
    elif 6 < level <= 7:
        return 21 - level
   [...]

The simple type2 graph I was trying to create didn't really turn out clean (I chopped off the upper section):

image

At any rate, is this possible to use discrete value correspondences? The basic idea is that "level" is an integer input, which corresponds to another discrete value, which in turn will be compared with other discrete values to get more discrete values, until a final discrete value is found. (You can see what I mean by checking out the react app at https://tunesmith.github.io/adnd-combat-tools/calculator - it's basically 5 discrete values that lead to the big integer on the right.)

Apologies if this isn't the right forum, I wasn't sure if this is feature request or just something supported that I don't know how to do.

lefakkomies commented 1 year ago

Maybe scale-type manual point is needed? [http://lefakkomies.github.io/pynomo-doc/axes/axes.html#manual-point-scale-scale-type-manual-point]