function [value,isterminal,direction] = events_rock_stop_ug(t,y,alpha,p,time_r,record_dt,ug)


% Locate the time when height passes through zero and stop integration.


value = [y(1) abs(y(1))-pi/2];     % Detect theta = 0
isterminal = [1 1];   % 1 Stop the integration; 0 Do not stop
direction = [0 0];   % 1 when function is increasing; -1 when function is decreasing; 0 always 