plotConservative.py
1 #!/usr/bin/env python
2 
3 
36 
37 # Authors: Caleb Voss, Wilson Beebe
38 
39 
40 import matplotlib.pyplot as plt
41 from mpl_toolkits.mplot3d import Axes3D
42 from pylab import *
43 from matplotlib import cm
44 
45 def potential(x, y):
46  return 1 + np.sin(x) * np.sin(y)
47 
48 def potentialSurface():
49  X = np.arange(-8, 8, 0.25)
50  Y = np.arange(-8, 8, 0.25)
51  X, Y = np.meshgrid(X, Y)
52  Z = potential(X, Y)
53  return X, Y, Z
54 
55 fig = plt.figure()
56 ax = fig.gca(projection='3d', aspect='equal')
57 X, Y, Z = potentialSurface()
58 ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0)
59 
60 x = np.loadtxt("vfrrt-conservative.path")
61 ax.plot(x[:,0], x[:,1], potential(x[:,0], x[:,1]), color='b')
62 
63 x = np.loadtxt("trrt-conservative.path")
64 ax.plot(x[:,0], x[:,1], potential(x[:,0], x[:,1]), color='r')
65 x = np.loadtxt("rrtstar-conservative.path")
66 ax.plot(x[:,0], x[:,1], potential(x[:,0], x[:,1]), color='g')
67 
68 plt.show()
69