Okay class.
I have assigned you the following problem.

A similar but yet different problem can be solved using this code:
GlowScript 3.0 VPython
#green grass
mybox = box(pos=vector(0,-5,0), size=vector(20,0.1,20),color=color.green)
#ball
ball = sphere(pos=vector(0,-4.8,0),radius=0.5,color=color.red, make_trail=True)
#Add Part Two
tgraph = graph(xtitle = 'Time(s)',ytitle = 'Pos(m)')
f1 = gcurve(color=color.red)
initialVelocity = vector(2,10,2)
TimeStep = 0.01
Acc = vector(0,-9.81,0)
Velocity = initialVelocity
time = 0
while ball.pos.y > -5:
rate(20)
Velocity = Velocity + Acc * TimeStep
ball.pos = ball.pos + Velocity * TimeStep
time = time + TimeStep
f1.plot(time, ball.pos.y)
How do you modify the code for this problem?





Leave a Reply