ENU2AER convert ENU to azimuth, elevation, slant range

Contents

Inputs

outputs

function [az, elev, slantRange] = enu2aer(east, north, up, angleUnit)
if nargin < 4
  angleUnit = 'd';
end

if abs(east) < 1e-3, east = 0.; end  % singularity, 1 mm precision
if abs(north) < 1e-3, north = 0.; end  % singularity, 1 mm precision
if abs(up) < 1e-3, up = 0.; end  % singularity, 1 mm precision

r = hypot(east, north);
slantRange = hypot(r,up);
% radians
elev = atan2(up,r);
az = mod(atan2(east, north), 2*pi);

if strncmp(angleUnit, 'd', 1)
  elev = rad2deg(elev);
  az = rad2deg(az);
end

end