from math import *
window = gr.GraphWin("Модель математического маятника", 800, 800)
len = 300
angle = pi/4
aVel = 0
aAcc = 0
g = 9.8
damping = 0.99
def clear_window():
rectangle = gr.Rectangle(gr.Point(0, 0), gr.Point(800, 800))
rectangle.setFill('yellow')
rectangle.draw(window)
while(True):
clear_window()
x = 400+len * sin(angle)
y = len * cos(angle)
my_line = gr.Line(gr.Point(400,0), gr.Point(x, y))
my_circle = gr.Circle(gr.Point(x, y), 10)
my_line.draw(window)
my_circle.draw(window)
#aAcc = -0.01*sin(angle)
aAcc = (-1*g/len)*sin(angle)
aVel*=damping
aVel+=aAcc
angle+= aVel
http://judge.mipt.ru/mipt_cs_on_python3/labs/lab5.html
https://www.youtube.com/watch?v=9iaEqGOh5WM
Немає коментарів:
Дописати коментар