use c style instead of python style in cython
[liba.git] / python / test / trajbell.py
blob1c064277b8f4b93a92be4898977260a62b44a6bb
1 #!/usr/bin/env python
2 import os, sys
4 sys.path.insert(0, os.getcwd())
5 prefix = os.path.join(sys.path[0], "build")
6 if not os.path.exists(prefix):
7 os.mkdir(prefix)
8 try:
9 import liba as a
10 import numpy as np
11 import matplotlib.pyplot as plt
12 except Exception as e:
13 print(e)
14 exit()
16 traj = a.trajbell()
17 traj.gen(3, 2, 3, 0, 10)
18 data = np.arange(0, traj.t, 0.01)
19 plt.figure("bell-shaped velocity trajectory")
21 plt.subplot(411)
22 plt.title("bell-shaped velocity trajectory")
23 plt.ylabel("Position")
24 plt.plot(data, traj.pos(data), "r-", label="q")
25 plt.legend()
27 plt.subplot(412)
28 plt.ylabel("Velocity")
29 plt.plot(data, traj.vel(data), "b-", label="v")
30 plt.legend()
32 plt.subplot(413)
33 plt.ylabel("Acceleration")
34 plt.plot(data, traj.acc(data), "g-", label="a")
35 plt.legend()
37 plt.subplot(414)
38 plt.ylabel("Jerk")
39 plt.plot(data, traj.jer(data), "k-", label="j")
40 plt.legend()
42 plt.xlabel("t")
43 plt.savefig(os.path.join(prefix, "bell-shaped_trajectory.png"))