#!/usr/local/bin/perl # ~/bin/logscale.p # usage $extend=1.0125 ; $pic = 1 ; # which picture to do 2 is a single 1-10 $scale1 = 1.1 ; # metre $scale2 = $scale1/39.37007874015748 ; # inches $scale3 = $scale2 *12.0 ; # feet $l = 1.4 ; # point size $font = "\\footnotesize" ; $verbose = 0 ; $X = 50 ; $Y = 27 ; $N = 2 ; $t = 1 ; $o = 1 ; $D = 10 ; $o2 = 2*$t ; # How to override min and max values with command line eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $X *= $N ; sub hline { # IGNORE THIS!!!!!!!!!!! local( $start , $x , $y ) = @_ ; $Xf = sprintf("%10.4f", $X*$extend ); print "\\put($x,$y){\\vector(1,0){$Xf\}\}\n" ; $yy = $y - $o ; LOOP: for ($n=1;$n<=$N+14;$n++) { $xx = (log($start)/log($D) + ($n-1))*$X/$N ; LOOPD: for ($d=1;$d<$D;$d++) { $xxx = sprintf("%10.4f", $xx + log( $d )*$X/$N /log($D) ); if ($xxx>$X) { last LOOP; } if ($xxx<$x-1) { print STDERR "leaving off $n $d $xxx $x \n" ; next LOOPD; } print "\\put($xxx,$y){\\line(0,1){$t\}\}\n" ; print "\\put($xxx,".$yy."){\\makebox(0,0)[t]{$d"."0"x($n-1)."\}\}\n" ; } } } sub line { local( $start , $x , $y , $title ) = @_ ; $Xf = sprintf("%10.4f", $X*$extend ); $yy = $y + $o2 ; $xx = $x - $o ; print "\\put($y,$xx){\\makebox(0,0)[tl]{$font\{$title}\}\}\n" ; if ($extend>1) { print "\\put($y,$x){\\vector(0,1){$Xf\}\}\n" ; } else { print "\\put($y,$x){\\line(0,1){$Xf\}\}\n" ; } LOOP: for ($n=1;$n<=$N+14;$n++) { $xx = $x + (log($start)/log($D) + ($n-1))*$X/$N ; LOOPD: for ($d=1;$d<$D;$d++) { $xxx = sprintf("%10.4f", $xx + log( $d )*$X/$N /log($D) ); if ($n==1 ) { $xxx{$d} = $xxx ; $xxxa{$d} = $xx + log( $d+1.0 )*$X/$N /log($D) ; } if ($xxx>$X+1) { last LOOP; } if ($xxx<$x-1) { print STDERR "leaving off $n $d $xxx $x \n" ; next LOOPD; } print "\\put($y,$xxx){\\line(1,0){$t\}\}\n" ; print "\\put(".$yy.",$xxx){\\makebox(0,0)[l]{$font\{$d"."0"x($n-1)."}}}\n" ; } } if ($pic==2) { # draw arrows $yy= $y-$o ; $yyy = $yy - 1 ; $d = 1 ; &doit ; $d = 3 ; &doit ; $d = 9 ; &doit ; } } sub doit { $xb = $xxx{$d} ; $xa = $xxxa{$d} ; $x = sprintf("%10.4f", ($xa+$xb)/2.0 ) ; $len = sprintf("%10.4f", ($xa-$xb)/2.0 ) ; print "\\put($yy,$x){\\vector(0,1){$len\}\}\n" ; print "\\put($yy,$x){\\vector(0,-1){$len\}\}\n" ; print "\\put($yyy,$x){\\makebox(0,0)[r]{$font\{\$P($d)\$}}}\n" ; } print '% written by logscale.p (c) DJCM Feb 2000'."\n" ; print '% see ignorance.tex '."\n" ; if ($pic==1) { print '\setlength{\unitlength}{'."$l"."mm}\n" ; # print '\begin{picture}('."$X,$Y)(0,0)\n" ; print '\begin{picture}('."$Y,$X)(0,0)\n" ; &line( $scale1 , 3 , 0 , "metres" ) ; &line( $scale2 , 3 , 2*$Y/3 , "inches" ) ; &line( $scale3 , 3 , $Y/3 , "feet" ) ; print "\\end{picture} \n" ; } else { print '\setlength{\unitlength}{'."$l"."mm}\n" ; # print '\begin{picture}('."$X,$Y)(0,0)\n" ; print '\begin{picture}('."$Y,$X)(0,0)\n" ; &line( 1 , 0 , $Y-3 , "" ) ; print "\\end{picture} \n" ; } print STDERR "DONE\n" ;