d = 50
v_0 = 25
theta = pi/3
t = var('t')
x_t(t) = v_0*cos(theta)*t
y_t(t) = v_0*sin(theta)*t - (9.8/2)*t^2
t_wall = d / (v_0*cos(theta))
delta_t = 0.000001
t_before_wall = t_wall - delta_t
position_at_wall = (x_t(t_wall), y_t(t_wall))
position_before_the_wall = (x_t(t_before_wall), y_t(t_before_wall))
height_of_impact = y_t(t_wall)
print "Position at wall is: " + str(position_at_wall)
print "Position before wall: " + str(position_before_the_wall)
print "Hits wall at: " + str(N(t_wall,digits=7)) + " seconds."
print "Hits wall at: " + str(height_of_impact) + " meters above the ground."
slope = (position_before_the_wall[1]-position_at_wall[1])/(position_before_the_wall[0]-position_at_wall[0])
angle_impact = arctan(slope)
dif_x = (position_at_wall[0]-position_before_the_wall[0])^2
dif_y = (position_at_wall[1]-position_before_the_wall[1])^2
distance_between_points = sqrt(dif_x + dif_y)
velocity_impact = distance_between_points/delta_t
x_t_b(t) = d-velocity_impact*cos(-angle_impact)*t
y_t_b(t) = y_t(t_wall)-velocity_impact*sin(-angle_impact)*t-9.8/2*t^2
t_ground = find_root(y_t_b == 0, 0, d)
container = Graphics()
container += parametric_plot ( (x_t(t), y_t(t)), (t,0,t_wall) )
container += parametric_plot( (d, t), (t,0,position_at_wall[1]+5), color='green', thickness=5)
container += parametric_plot( (x_t_b(t), y_t_b(t)), (t,0,t_ground))
show(container)
container.save('with_gravity_with_wall.pdf')
Position at wall is: (50, 50*sqrt(3) - 78.4000000000000)
Position before wall: (49.9999875000000, 49.9999875000000*sqrt(3) - 78.3999608000049)
Hits wall at: 4.000000 seconds.
Hits wall at: 50*sqrt(3) - 78.4000000000000 meters above the ground.
