#!/usr/bin/perl
#
# Graphs for practice computing Work
#
# MWR 1/24/2009

$debug = 1;

$title = "Wind blows a piece of paper across the quad";
$cmdfile = "./wind_paper_a.gnu";
$psfile = "./wind_paper_a.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n ";
printf CMDFILE "set term postscript mono \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top left \n";
printf CMDFILE "set xlabel 'position of paper North of wastebasket (meters)'  \n";
printf CMDFILE "set ylabel 'force of wind to North (Newtons)'  \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [0.0:5.0][-0.3:1.0] ";
printf CMDFILE "    x*0.10 with lines lw 3 t '' ";
printf CMDFILE " \n";
printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;



$title = "Wind blows a piece of paper across the quad";
$cmdfile = "./wind_paper_b.gnu";
$psfile = "./wind_paper_b.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n ";
printf CMDFILE "set term postscript mono \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top left \n";
printf CMDFILE "set xlabel 'position of paper North of wastebasket (meters)'  \n";
printf CMDFILE "set ylabel 'force of wind to North (Newtons)'  \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [0.0:5.0][-0.3:1.0] ";
printf CMDFILE "    0.2-x*0.4+0.1*x*x with lines lw 3 t '' ";
printf CMDFILE " \n";
printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;




exit 0;
