import graphics as gr
from math import *
window = gr.GraphWin("Модель перевернутого маятника", 800, 800)
len = 300
angle = pi/4
aVel = 0
aAcc = 0
aVel2=0
aAcc2=0
g = 9.8
m=0.5
M=1
b=m/(m+M)
j=m*len*len
#x=400
#y=50
x2=0
y2=0
def clear_window():
rectangle = gr.Rectangle(gr.Point(0, 0), gr.Point(800, 800))
rectangle.setFill('yellow')
rectangle.draw(window)
while(True):
clear_window()
x1 = 400+len * sin(angle)
y1 = 50+len * cos(angle)
my_line = gr.Line(gr.Point(400+x2,360+y2), gr.Point(x1, y1))
my_circle1 = gr.Circle(gr.Point(x1, y1), 10)
#my_rectangle = gr.Rectangle(gr.Point(360, 360), gr.Point(440, 400))
my_circle2 = gr.Circle(gr.Point(400+x2,360+y2), 20)
my_line.draw(window)
my_circle1.draw(window)
my_circle2.draw(window)
#my_rectangle.draw(window)
angle+= aVel
aVel+=aAcc
aAcc = (g*sin(angle)+b*len*aVel*aVel*sin(angle)*cos(angle))/(len*(1+b*cos(angle)**2))
x2+=aVel2
aVel2+=aAcc2
aAcc2=b*(len*aVel*aVel*sin(angle)-g*sin(angle)*cos(angle))/(1+b*cos(angle)**2)
https://habr.com/ru/post/472588/
from math import *
window = gr.GraphWin("Модель перевернутого маятника", 800, 800)
len = 300
angle = pi/4
aVel = 0
aAcc = 0
aVel2=0
aAcc2=0
g = 9.8
m=0.5
M=1
b=m/(m+M)
j=m*len*len
#x=400
#y=50
x2=0
y2=0
def clear_window():
rectangle = gr.Rectangle(gr.Point(0, 0), gr.Point(800, 800))
rectangle.setFill('yellow')
rectangle.draw(window)
while(True):
clear_window()
x1 = 400+len * sin(angle)
y1 = 50+len * cos(angle)
my_line = gr.Line(gr.Point(400+x2,360+y2), gr.Point(x1, y1))
my_circle1 = gr.Circle(gr.Point(x1, y1), 10)
#my_rectangle = gr.Rectangle(gr.Point(360, 360), gr.Point(440, 400))
my_circle2 = gr.Circle(gr.Point(400+x2,360+y2), 20)
my_line.draw(window)
my_circle1.draw(window)
my_circle2.draw(window)
#my_rectangle.draw(window)
angle+= aVel
aVel+=aAcc
aAcc = (g*sin(angle)+b*len*aVel*aVel*sin(angle)*cos(angle))/(len*(1+b*cos(angle)**2))
x2+=aVel2
aVel2+=aAcc2
aAcc2=b*(len*aVel*aVel*sin(angle)-g*sin(angle)*cos(angle))/(1+b*cos(angle)**2)
https://habr.com/ru/post/472588/
Немає коментарів:
Дописати коментар