-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathPyRainey.py
80 lines (61 loc) · 1.49 KB
/
PyRainey.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Lorenz.py
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from random import *
from numpy import *
import sys
# Globals for window width and height
global width
global height
# Initial values of width and height
width = 250
height = 250
def init():
# White background
glClearColor(1.0, 1.0, 1.0, 0.0)
# Set the projection matrix... our "view"
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
# Set the plot window range
# This will coincide with the for... arange loops
gluOrtho2D(-5.0, 5.0, -5.0, 5.0)
# Set the matrix for the object we are drawing
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
def plotroessler():
glClear(GL_COLOR_BUFFER_BIT)
# Initial values
x = 1.0
y = 1.0
z = 1.0
dt = 0.001
glColor3f(1.0,0.0,0.0)
glBegin(GL_POINTS)
for n in arange(-90.0, 90.0, 0.0001):
x = x + (-2*x + z*y)*dt
y = y + (-2*y + (z - 5)*x)*dt
z = z + (1 - x*y)*dt
glColor3f(sin(z),cos(x),sin(y))
glVertex2f(y,z-5)
glEnd()
glFlush()
def keyboard(key, x, y):
# Allows us to quit by pressing 'Esc' or 'q'
if key == chr(27):
sys.exit()
if key == "q":
sys.exit()
def main():
global width
global height
glutInit(sys.argv)
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE)
glutInitWindowPosition(100,100)
glutInitWindowSize(width,height)
glutCreateWindow("Rikitake")
glutDisplayFunc(plotroessler)
glutKeyboardFunc(keyboard)
init()
glutMainLoop()
main()