Question
can you please finish this code. Defining Net Force: 1. What force is acting on the ball? Define this force, as a vector, in the
can you please finish this code.
Defining Net Force: 1. What force is acting on the ball? Define this force, as a vector, in the space below.
2. Translate this expression to VPython coding language in the box below and change the value inside the vector for Fnet in your code.
Updating Momentum from Net Force: Since there is a net force acting on the ball, modeling the balls motion is not as simple as just updating the position of the ball. The balls momentum will also need to be updated BEFORE each new position.
3. Write the mathematical equation to update momentum in the box below. Use the following variables: Fnet (net force), pi (initial momentum), pf (final momentum), and t (change in time).
4. Translate the above equation into VPython notation in the box below. Add this expression to the while loop in your program.
Updating Position from Momentum:
5. Write the mathematical equation to update position in the box below. Use the following variables: ri (initial position), rf (final position), p (momentum), m (mass), and t (change in time).
6. Translate the above equation into VPython notation in the box below. Add this expression to the while loop in your program.
Web VPython 3.2 scene.background=color.white # change background color floor=box(pos=vec(0,-0.02,0),size=vec(6,0.02,0.6),opacity=0.5,color=color.green) #create ground ball=sphere(pos=vec(-3,0,0), radius=0.06, color=color.blue, make_trail=True,trail_type='points') # create projectile (ball) force_arrow = arrow(pos=ball.pos, axis=vector(1,1,0), shaftwidth=0.05, color=color.green) #create force vector momentum_arrow = arrow(pos=ball.pos, axis=vector(1,1,0),shaftwidth=0.05, color=color.red) #create momentum vector
g=9.8 # acceleration due to gravity in N/kg ball.m=0.1 # mass of ball in kg v0=7 # initial launch speed in m/s theta=55 # initial launch angle in degrees vhat=vec(cos(theta*pi/180),cos((90-theta)*pi/180),0) # initial velocity unit vector ball.p=ball.m*v0*vhat # initial momentum of ball
t=0 # start time dt=0.01 # time step
YPositionGraph = graph(title='Y-Position vs Time', xtitle='Time (s)', ytitle='Position, y (m)', fast=False, width=800) #create position vs time graph YPositionVsTime = gcurve(color=color.blue, width=2, label='Position, y')
while True: # while loop start rate(100) Fnet=vec(0, 0, 0) #net force on ball
force_arrow.axis = Fnet #adjust arrow axis force_arrow.pos = ball.pos #update arrow position momentum_arrow.axis = ball.p #adjust arrow axis momentum_arrow.pos = ball.pos #update arrow position t=t+dt YPositionVsTime.plot(t, ball.pos.y) # append data to graph print(ball.pos.x, "final x-position (m)") #print final x-position
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started