import numpy as np import sys import os sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '..')) from scipy.integrate import odeint import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from Program import Program from Command import Command # Lorenz paramters and initial conditions sigma, beta, rho = 10, 2.667, 28 u0, v0, w0 = 0, 1, 1.05 # Maximum time point and total number of time points tmax, n = 100, 10000 def lorenz(X, t, sigma, beta, rho): """The Lorenz equations.""" u, v, w = X up = -sigma*(u - v) vp = rho*u - v - u*w wp = -beta*w + u*v return up, vp, wp # Integrate the Lorenz equations on the time grid t t = np.linspace(0, tmax, n) f = odeint(lorenz, (u0, v0, w0), t, args=(sigma, beta, rho)) x, y, z = f.T pts=[] _x = x+y _y=z pts=(_x,_y) print(pts) plt.plot(_x,_y) # Plot the Lorenz attractor using a Matplotlib 3D projection fig = plt.figure() ax = fig.gca(projection='3d') plt.show() def lorenz(plt): list=hilbert(min(plt.winsize[0],plt.winsize[1]),penthickness) return Program([Command('IN'),Command('SP1'),Command('PU',*list[0])]\ +[Command('PD',*p) for p in plt]\ +[Command('PU')]) # Remove all the axis clutter, leaving just the curve. #ax.set_axis_off()