-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rolling_ball.py
48 lines (40 loc) · 1.23 KB
/
Rolling_ball.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
from graphics import *
from math import *
x0,y0=100,27
r=50
#h,l=[int(x) for x in input().split()]
h,l=500,500
win=GraphWin("Rolling_ball",1000,1000)
theta=(sqrt((h**2)+(l**2))*360)/(pi*l*2*r)
b=l
for x in range(100,1000):
rad1 = theta * 3.14/ 180;
rad2 = (theta + 90) * 3.14/ 180;
Line(Point(100, 100), Point(100, 100 + h)).draw(win)
Line(Point(100, 100 + h), Point(1000, 100 + h)).draw(win)
Line(Point(100, 100), Point(100 + l, 100 + h)).draw(win)
Circle(Point(x0,y0), 50).draw(win)
Line(Point(x0 , y0), Point(x0 + r * sin(rad1), y0 + r * cos(rad1))).draw(win)
Line(Point(x0, y0), Point(x0 + r * sin(rad2), y0 + r * cos(rad2))).draw(win)
Line(Point(x0, y0), Point(x0 - r * sin(rad1), y0 - r * cos(rad1))).draw(win)
Line(Point(x0, y0), Point(x0 - r * sin(rad2), y0 - r * cos(rad2))).draw(win)
# win.delete("all")
# theta-=8
# time.sleep(.1)
if x>=120+l and x <900:
win.delete("all")
theta -= 6.5*x / b
b+=10
x0=x
time.sleep(b / (150 * x))
elif x<125+l:
win.delete("all")
y0+=h/l
theta -= 7.5* x / l
time.sleep(l / (150 * x))
x0 = x
else:
win.getMouse()
break
win.getMouse()
win.close()