lab8 CLOSE

 avatar
unknown
python
a month ago
1.2 kB
3
Indexable
Lab08 by Daniel Sargis   2025/03/20 10:58:47
Run this program Share or export this program Download

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
dt = 0.001
KE_graph = graph(title='Kinetic Energy vs Time', xtitle='t (s)', ytitle='K (J)')
KE_ball_curve = gcurve(graph=KE_graph, color=color.red)
KE_stone_curve = gcurve(graph=KE_graph, color=color.black)
W_graph = graph(title='Work Done vs Time', xtitle='t (s)', ytitle='W (J)')
W_ball_curve = gcurve(graph=W_graph, color=color.blue)
W_stone_curve = gcurve(graph=W_graph, color=color.green)
while stone.pos.y >= ground.pos.y : 
    
    rate(200)
    
    F_ball = ball.mass * vec(0,0,0)
    
    ball.p = ball.p + F_ball*dt
    ball.v = ball.p/ball.mass
    ball.pos = ball.pos + ball.v*dt
    
    W_ball = F_ball * (ball.v.y * dt) + W_ball
    
    
    
    
    
    F_stone = stone.mass * vec(0,-g,0)
    
    stone.p = stone.p + F_stone*dt
    stone.v = stone.p/stone.mass
    stone.pos = stone.pos + stone.v*dt
    
    W_stone = F_stone * (stone.v.y * dt) + W_stone
    
    
    
    K_ball_new = 0.5 * ball.mass * mag(ball.v) ** 2
           
Editor is loading...
Leave a Comment