function BW_3dB=beamwidth(f,L,theta0)
%
% Computes the 3-dB beamwidth of a line array of length L at frequency f at angle theta0 from
% broadside.  Formula from Handbook of Array Design Technology, Applied Hydroacoustics Research,
% Inc.  Assume a sound speed of 1500 m/s.
% 
% Call BW_3dB=beamwidth(f,L,theta0)
%
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
lambda=1500./f;
if abs(theta0)<70,
    BW_3dB=0.886*(lambda./L)*sec(theta0*pi/180) * (180/pi);
else
    disp('NOTE: Using near-endfire formula ...');
    BW_3dB=2 * sqrt( 0.886*(lambda./L) ) * (180/pi);
end
