function dist = miss_distance(v0);

% Purpose:
% For an initial velocity v0 (2-vector vx,vy), find out how
% badly we missed the shot. To do this, we must know the
% goals x1,y1,t1. These come to us from the driver program
% as global variables.

global x1 y1 t1 trajectory_plot_style

% initial values
x0 = [0,0];
q0 = [x0,v0];
t0 = 0.0;

dt = 0.1;
nsteps = (t1-t0)/dt;

trajectory=rk2(q0,t0,dt,nsteps,'basketball');

x = trajectory(:,1);
y = trajectory(:,2);
plot(x,y,trajectory_plot_style);

% final values:
xf = x(nsteps+1);
yf = y(nsteps+1);

% missed it by this much:
v0
dist = norm( [xf-x1, yf-y1] )