Cannon (Program in Python with PyQtGraph wrapper)
Previous post includes an animated graph, which is concatenation of png images, created by Giam software. The graphs are drawn by python program with a graphics library, PyQtGraph. Here is the source code. The package pyqtgraph_wrapper is my self-making wrapper of PyQtGraph.
# -*- coding: utf-8 -*- """ Sample code for pyqtgraph_wrapper Created on Fri Jun 3 13:05:30 2016 @author: tatsuya-y """ import sys import time import numpy as np import scipy as sp sys.path.append('./pyqtgraph_wrapper') import pyqtgraph_wrapper as pgw ## Cannon win = pgw.figure() i = 0 tsnap = 50 T = 5000 y = np.arange(0, 1, 0.001) for t in np.arange(T): a = sp.tan(sp.pi/2 * t/T) x = sp.sqrt(a**2 * (1 - y**2)) win.clf() win.hold() win.plot(x, y, color="#ffffff") win.plot(x, -y, color="#ffffff") win.ylim(-2, 2) win.xlim(1, 100) #win.drawnow() print('t = {0:0>4}'.format(t)) if t == 0 or t == T-1 or sp.mod(t,tsnap) == 0: win.print('cannon_img\cannon_{0:0>4}.png'.format(i)) i = i + 1 time.sleep(0.1)
The wrapper pyqtgraph_wrapper is under development. I'm planning to open a github repository after making the rough list of TODOs or Tasks.