forked from bbw7561135/Numerical-Algorithms-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimate2D.gnu
More file actions
42 lines (40 loc) · 1.62 KB
/
animate2D.gnu
File metadata and controls
42 lines (40 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Usage: In order to animate data in file.dat do the following:
# gnuplot> file = "file.dat"
# gnuplot> t0 = 0
# gnuplot> tf = 10
# gnuplot> dt = 0.01
# gnuplot> set xrange [-10:10];set yrange [-10:10]
# gnuplot> load "animate2D.gnu"
set macros
set size square
# -----------------------------
t0 = t0 + dt
command = "awk -v t=".sprintf("%f",t0)." '$1<t{print $2}' ".file."|tail -n 1"
x0 = `@command`
command = "awk -v t=".sprintf("%f",t0)." '$1<t{print $3}' ".file."|tail -n 1"
y0 = `@command`
set arrow 1 from 0,0 to x0,y0
# show arrow 1
# set title "t= ".sprintf("%f (x,y) = %s",t0,axy)
set title "t= ".sprintf("%f (x,y)= (%f,%f)",t0,x0,y0)
plot file \
using 2:($1<= t0 ? $3: 1/0) with lines notitle
# pause sleep
if(t0<tf) reread
# ---------------------------------------------------------------------
# Copyright by Konstantinos N. Anagnostopoulos (2004-2014)
# Physics Dept., National Technical University,
# [email protected], www.physics.ntua.gr/~konstant
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public Liense along
# with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------