GNUPlot中的弹丸运动及其颜色

时间:2015-03-13 16:31:38

标签: animation gnuplot projectile

您好我尝试使用GNUPlot进行射弹运动。

这是我制作剧本的方式,首先我定义了y的函数(y中的初始速度为零,x中的初始速度为1,初始垂直位置为yinit = 34,初始水平位置为零(原点))

(抱歉无效的制作方法,我在这里很新)

set term post eps color enhanced font "Times, 24"
set size 1.2, 0.8
set bmargin 3.5

set xlabel "{/Italic x} (m)" font "Times, 30"
set xtics 0 0.5 font "Times, 28"
set mxtics 4
set xrange[0:2.5]

set ylabel "{/Italic y} (m)" font "Times, 30"
set ytics 5 font "Times, 28"
set mytics 2
set yrange [0:40]

set grid xtics ytics mxtics mytics

yinit = 34
vxinit = 1
gr = -9.8
y(t) = yinit + 0.5*gr*t*t 
x(t) = vxinit*t

t = 0.0
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""


t = 0.1
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.2
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.3
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.4
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.5
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.6
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.7
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.8
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 0.9
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

t = 1.0
timestamp = sprintf("{/Italics t} = %1.2f Sekon", t);
filename = sprintf("projectile-%1.1f.eps", t);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(t) w p pt 5 ps 2.5 t ""
plot x(t) w p pt 5 ps 2.5 t ""

(仍然无法在此处发布图片,仍然声名鹊起)

关于颜色,我想制作蓝色

1 个答案:

答案 0 :(得分:0)

您需要一个参数图:在独立变量的不同步骤绘制(x,y)位置:

yinit = 34
vxinit = 1
gr = -9.8
y(t) = yinit + 0.5*gr*t*t 
x(t) = vxinit*t

set parametric
set trange [0:1]
set samples 11
plot x(t), y(t)  with linespoints pt 7 lc rgb 'blue'

enter image description here