#! /bin/csh -f # Last edited on 2001-11-03 02:20:36 by stolfi set usage = "$0 [-complement] [-plotWidth NUM] [-plotRelWidth NUM] [-plotRelHeight NUM] [-shift NUM] [-sampleDots] INFILE EPSNAME" # Reads an .fcv or .cvc file and plots a graph of # curvature as a function of sample number. # The "-complement" option negates both axes. # The "-shift NNN" option adds NNN to the length parameter, cyclically. # The "-plotWidth" option gives the nominal length of the curve (for X scaling). # The "-plotRelWidth" is the same, but in multiples of the sampling step.. set cmd = $0 echo "=== begin ${cmd:t} ===" echo "${cmd:t} $*" set sgn = "+1" set shf = 0 set plotWidth = 0 set plotRelWidth = 0 set style = "lines lt 1" while ( ( $#argv > 0 ) && ( "x$1" =~ x-* ) ) if ( "x$1" == "x-complement" ) then set sgn = "-1"; shift else if ( ( $#argv >= 2 ) && ( "x$1" == "x-shift" ) ) then set shf = "$2"; shift; shift else if ( ( $#argv >= 2 ) && ( "x$1" == "x-plotWidth" ) ) then set plotWidth = "$2"; shift; shift else if ( ( $#argv >= 2 ) && ( "x$1" == "x-plotRelWidth" ) ) then set plotRelWidth = "$2"; shift; shift else if ( "x$1" == "x-sampleDots" ) then set style = "linespoints lt 1 pt 7 pointsize 0.75"; shift else echo "usage: ${usage}"; exit 1 endif end if ( $#argv != 2 ) then echo "usage: ${usage}"; exit 1 endif set infile = "$1"; shift set epsname = "$1"; shift set ext = "${infile:e}" set inname = "${infile:r}" set tmpa = "/tmp/$$-${inname:t}-a.plt" set tmpb = "/tmp/$$-${inname:t}-b.plt" set lam = `cat ${infile:r}.lambda` echo "lambda = ${lam}" # Decode the curvature values if ( "${ext}" == "fcv" ) then cat ${infile} \ | gawk \ ' /^unit = / { unit=$3; next; } \ /^samples = / { print; next; } \ /^[-+ 0-9]/ { printf "%f\n", unit * $1; next; } \ ' \ > ${tmpa} else if ( "${ext}" == "cvc" ) then cat ${infile} \ | gawk \ ' /^samples = / { print; next; } \ /^ *[A-Za-z0] *$/ { \ let = $1; \ val = index("zyxwvutsrqponmlkjihgfedcba0ABCDEFGHIJKLMNOPQRSTUVWXYZ", let); \ if ((val == 0)||(length(let) != 1)) \ { printf "bad letter (%s)\n", let > "/dev/stderr"; } \ printf "%2d\n", val - 27; next; \ } \ ' \ > ${tmpa} else echo "bad extension ${ext}"; exit 1 endif # Apply the complementation and shift: cat ${tmpa} \ | gawk \ -v sgn="${sgn}" -v shf="${shf}" -v lam="${lam}" \ ' /^samples = / { n=$3; del = lam/4; len = n*del; next; } \ /^[-+ 0-9]/ { \ x = sgn * (i*del + shf); y = sgn * $1; i++; \ while (x >= len) { x -= len; } \ while (x < 0) { x += len; } \ printf "%.5f %f\n", x, y; next; \ } \ ' \ | sort -b +0 -1g \ > ${tmpb} echo "writing ${epsname}.eps" gnuplot < 0 ? xmax : 128) set xrange [(-0.03*xmax):(1.03*xmax)] # ymax = (0.125/${lam}) set yrange [(-ymax*1.03):(ymax*1.03)] set nokey set ylabel # set noxtics # set format x "" set format y "%.3f" set xlabel plot \ 0 with lines lt 2, \ "${tmpb}" using 1:2 with ${style} quit EOF ghostview ${epsname}.eps /bin/rm -f ${tmpa} ${tmpb} echo "=== end ${cmd:t} ========="