replace recursion with iteration
[liba.git] / python / test / trajtrap.py
blobcf30333263d9507639b485cf0e08d6289e7ff70c
1 #!/usr/bin/env python
2 from __future__ import print_function
3 import os, sys
5 path = os.path.dirname(__file__)
6 path = os.path.dirname(path)
7 sys.path.insert(0, path)
8 if len(sys.argv) > 1:
9 sys.stdout = open(sys.argv[1], "w")
11 import liba # type: ignore
13 traj = liba.trajtrap()
14 traj.gen(2, 2, -2, 0, 4)
16 N = 1000
17 T = traj.t / N
18 x = liba.new_num(N)
19 for i in range(N):
20 x[i] = i * T
22 p = traj.pos(x)
23 v = traj.vel(x)
24 a = traj.acc(x)
26 for i in range(N):
27 print("%g,%g,%g,%g" % (x[i], p[i], v[i], a[i]))
29 traj.t
30 traj.p0
31 traj.p1
32 traj.v0
33 traj.v1
34 traj.vc
35 traj.ta
36 traj.td
37 traj.pa
38 traj.pd
39 traj.ac
40 traj.de