ECEF2ENUV convert vector projection UVW to ENU

Contents

Inputs

Outputs

function [e, n, Up] = ecef2enuv(u, v, w, lat0, lon0, angleUnit)
if nargin < 6
  angleUnit = 'd';
end

if strncmp(angleUnit, 'd', 1)
  lat0 = deg2rad(lat0);
  lon0 = deg2rad(lon0);
end

t  =  cos(lon0) .* u + sin(lon0) .* v;
e  = -sin(lon0) .* u + cos(lon0) .* v;
Up =  cos(lat0) .* t + sin(lat0) .* w;
n  = -sin(lat0) .* t + cos(lat0) .* w;

% 1mm precision
if abs(e) < 1e-3, e=0; end
if abs(n) < 1e-3, n=0; end
if abs(Up) < 1e-3, Up=0; end
end