日曜日, 10月 20, 2013

gnuplot で矢印 : arrow diagram with gnuplot



#!/bin/bash

echo "vector_plot.sh"

##################################################
nDiv=20
outputfile="./output.tmp"

##################################################
pi=`echo "scale=5; 4.0*a(1.0)" | bc -l`
dtheta=`echo "scale=5; 2.0*${pi}/${nDiv}" | bc -l`

echo "  nDiv : "${nDiv}
echo "    pi : "${pi}
echo "dtheta : "${dtheta}


##################################################
rm -f ${outputfile}
touch ${outputfile}
theta=0.0
for i in `seq -w 1 ${nDiv}` ; do
    X=`echo "scale=5; c(${theta})" | bc -l`
    Y=`echo "scale=5; s(${theta})" | bc -l`
    echo 0.0 0.0 ${X} ${Y} >> ${outputfile}

    theta=`echo "scale=5; ${theta} + ${dtheta}" | bc -l`

done


##################################################
gnuplot << EOF
set out "output.gif"
set size square
set term gif
set grid
set pointsize 4
plot "${outputfile}" w vector pointtype 7 title ""
EOF







冒頭で,cos, sin を使って,X 座標, Y 座標を描かせてる.

シェルスクリプトで π をだすために

pi=`echo "scale=5; 4.0*a(1.0)" | bc -l`



という出し方を行う.

0 件のコメント: