#!/usr/bin/env perl

use strict;
use warnings;
use Math::Trig qw(pi);

my ( @values, @distances );

# Generate A scale values and distances according to what is present on
# a Pickett Model N 3P-ES pocket slide rule, though half-tick resolution
# has been used, or double the number of values than actually present,
# given that a human can guess when something is 9.1 despite there only
# being ticks at 9 and 9.2.
my $pad_by = 2;

# 1..3 at 20 ticks per digit, etc.
genvd( 1, 3,  20 );
genvd( 3, 6,  10 );
genvd( 6, 10, 5 );
# and similar pattern for next decade
genvd( 10, 30,  20 );
genvd( 30, 60,  10 );
genvd( 60, 100, 5 );

push @values,    100;
push @distances, log $values[-1];

# pi is indicated on the scale
push @values,    pi;
push @distances, log $values[-1];

@values    = sort { $a <=> $b } @values;
@distances = sort { $a <=> $b } @distances;

use Data::Dumper::Concise;
print Dumper { value => \@values, dist => \@distances };

exit 0;

sub genvd {
  my ( $min, $max, $precision ) = @_;

  my $ticks = $precision * ( $max - $min ) * $pad_by;
  my $slope = ( $max - $min ) / $ticks;
  for my $v ( 0 .. $ticks - 1 ) {
    push @values,    $slope * $v + $min;
    push @distances, log $values[-1];
  }
}
