Question
Consider a ball resting on the ground that is then kicked. This gives it a velocity of v at an angle of degrees from the
Consider a ball resting on the ground that is then kicked. This gives it a velocity of v at an angle of degrees from the horizontal x-axis. We can represent this ball using an object ball = Ball() and store its (x,y) position in ball.position. We want to use its method ball.step(delta_t) to update the position of the ball after a period of time delta_t has passed. Complete the code to achieve this. You may assume that acceleration due to gravity is 9.81ms-2, the ball is a point mass, there is no air resistance, and that the ball will collide inelastically with the ground!
For example:
import numpy as np class Ball(): def __init__(self, theta, v): self.position = np.array([0, 0]) # Position at ground is (0,0) # Fill this in. def step(self, delta_t = .1): # Fill this in. Update position before anything else!
V ay o >X ball-Ball () bell. position = (x,y] - Test Result ball Ball(theta = 30, v = 100) Ball is at x=866.63m, y=11.95m for t in range (200): ball.step(delta_t = 0.05) print(f'Ball is at x={ball.position[@]:.2f}m, y={ball.position[1]:.2f}m') # Check position ball Ball(theta 10, v = v = 5) Ball is at x=0.49m, y=0.04m for t in range (10): ball.step(delta_t = 0.01) = print(f'Ball is at x={ball.position[@]:.2f}m, y={ball.position[1]: 2f}m') # Check position ball = Ball(theta = 80, v = 600) Ball is at x=1041.89m, y=5423.25m for t in range (100): ball.step(delta_t = 0.1) print(f'Ball is at x={ball.position[@]:.2f}m, y={ball.position[1]:.2f}m') # Check position V ay o >X ball-Ball () bell. position = (x,y] - Test Result ball Ball(theta = 30, v = 100) Ball is at x=866.63m, y=11.95m for t in range (200): ball.step(delta_t = 0.05) print(f'Ball is at x={ball.position[@]:.2f}m, y={ball.position[1]:.2f}m') # Check position ball Ball(theta 10, v = v = 5) Ball is at x=0.49m, y=0.04m for t in range (10): ball.step(delta_t = 0.01) = print(f'Ball is at x={ball.position[@]:.2f}m, y={ball.position[1]: 2f}m') # Check position ball = Ball(theta = 80, v = 600) Ball is at x=1041.89m, y=5423.25m for t in range (100): ball.step(delta_t = 0.1) print(f'Ball is at x={ball.position[@]:.2f}m, y={ball.position[1]:.2f}m') # Check positionStep 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