forked from burakbayramli/books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyMayParabola.py
73 lines (56 loc) · 1.24 KB
/
PyMayParabola.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
# PyMayParabola.py
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from numpy import *
import sys
# Set the width and height of the window
global width
global height
# Initial values
width = 250
height = 250
def init():
glClearColor(1.0, 1.0, 1.0, 1.0)
gluOrtho2D(0.7333275,.7333375,0.7333275,.7333375)
def plotPolar():
glClear(GL_COLOR_BUFFER_BIT)
glPointSize(2.0)
glBegin(GL_POINTS)
r = 3.75
for x in arange(-1.0, 1.0,.0000001):
y = x*r*(1-x)
glColor3f(0.0, 0.0, 0.0)
glVertex2f(x,x)
glVertex2f(x,y)
glEnd()
x = .3
y = 0.0
glBegin(GL_LINE_STRIP)
for n in arange(1,5000000):
glColor3f(sin(x),cos(x*n),sin(n*y))
glVertex2f(x,y)
y = x*r*(1-x)
glVertex2f(x,y)
x = y
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(200,200)
glutInitWindowSize(width,height)
glutCreateWindow("Chaos")
glutDisplayFunc(plotPolar)
glutKeyboardFunc(keyboard)
init()
glutMainLoop()
main()