#! /usr/bin/perl
#To figure this out, consult Tim


$MAX = 300;
$NUM=999;
$counter=-1;
while ($counter < $MAX){
    $counter = $counter + 1;
     $NUM=$NUM+1;
    $LEFT=3 + ($counter/$MAX)*(0.449);
     $RIGHT=4 - ($counter/$MAX)*(0.347);
     $BOTTOM=0 + ($counter/$MAX)*(0.284);
     $TOP=1 - ($counter/$MAX)*(0.301);
     $file="bif.dat";
    $DIV=0.0001 * (30/($counter+1));
    system("echo '#include <stdlib.h>' > first.c");
    system("echo '#include <math.h>' >> first.c");
    system("echo '#include <fstream.h>' >> first.c");
    system("echo '#include <iostream.h>' >> first.c");
    system("echo '#include <strstream.h>' >> first.c");
    system("echo 'int main(){'>>first.c");
    system("echo 'ofstream outf(\"$file\");' >> first.c");
    system("echo 'double r=$LEFT;' >> first.c");
    system("echo 'double FIN=$RIGHT;' >> first.c");
    system("echo 'double BOTTOM=$BOTTOM;'>>first.c");
    system("echo 'double TOP=$TOP;'>>first.c");
    system("echo 'double NUMO=$DIV;'>>first.c");
    system("cat short.a >> first.c");
    system("g++ -o first first.c");
    system("./first");
    $file2="front.".$NUM.".ps";
    $stuff= readpipe "echo 'set terminal postscript' > gnu0001.dat";
    $stuff=readpipe"echo 'set pointsize 0.1' >> gnu0001.dat";
    $stuff=readpipe"echo 'set nokey' >> gnu0001.dat";
    $stuff=readpipe"echo 'set noxtics' >> gnu0001.dat";
    $stuff=readpipe"echo 'set noytics' >> gnu0001.dat";
    $stuff = readpipe "echo 'set output \"$file2\"'>> gnu0001.dat";
    $stuff = readpipe "echo 'plot [$LEFT:$RIGHT][$BOTTOM:$TOP] \"$file\" with points' >> gnu0001.dat";
    system("gnuplot gnu0001.dat");
    system("mogrify -format gif $file2");
    $file3="front.".$NUM.".gif";
    system("mogrify -rotate 90 $file3");
    system("rm $file2");
}

