function [xdot,isterminal,direction]= tennisip2(t,x,flag)
global g
if nargin < 3 | isempty(flag) % normal output
   xdot = [x(3), x(4), 0, -g]';
else
   switch(flag)
   case 'events'  % at ||h||=0 there is a singularity
      xdot= x(2);
      isterminal= 1;
      direction= -1;
   otherwise
      error(['Unknown flag ''' flag '''.']);
   end
end

