diff options
Diffstat (limited to 'inst/ecef2enu.m')
-rw-r--r-- | inst/ecef2enu.m | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/inst/ecef2enu.m b/inst/ecef2enu.m index 4d49f19..d67b385 100644 --- a/inst/ecef2enu.m +++ b/inst/ecef2enu.m @@ -1,6 +1,6 @@ -## Copyright (C) 2014-2020 Michael Hirsch, Ph.D. -## Copyright (C) 2013-2020 Felipe Geremia Nievinski -## Copyright (C) 2020 Philip Nienhuis +## Copyright (C) 2014-2022 Michael Hirsch, Ph.D. +## Copyright (C) 2013-2022 Felipe Geremia Nievinski +## Copyright (C) 2020-2022 Philip Nienhuis ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are met: @@ -69,7 +69,7 @@ ## u = 939.10 ## @end example ## -## @seealso {enu2ecef, ecef2enuv, ecef2geodetic, ecef2ned, ecef2enu, +## @seealso{enu2ecef, ecef2enuv, ecef2geodetic, ecef2ned, ecef2enu, ## referenceEllipsoid} ## @end deftypefn @@ -100,6 +100,9 @@ function [e,n,u] = ecef2enu (varargin) spheroid = varargin{7}; angleUnit = varargin{8}; endif + if (isnumeric (spheroid)) + spheroid = num2str (spheroid); + endif x = varargin{1}; y = varargin{2}; @@ -124,24 +127,18 @@ function [e,n,u] = ecef2enu (varargin) if (! all (size (lat0) == size (x)) || ... ! all (size (lon0) == size (y)) || ... ! all (size (alt0) == size (z))) - error ("ecef2enu: non-matching dimensions of observer points and \ -target points"); + error (["ecef2enu: non-matching dimensions of observer points and ", ... + "target points"]); endif endif - if (isempty (spheroid)) - E = wgs84Ellipsoid; - elseif (isstruct (spheroid)) - E = spheroid; - else - E = referenceEllipsoid (spheroid); - endif + E = sph_chk (spheroid); if (! ischar (angleUnit) || ! ismember (lower (angleUnit(1)), {"d", "r"})) error ("ecef2enu: angleUnit should be one of 'degrees' or 'radians'") endif - [x0, y0, z0] = geodetic2ecef (spheroid, lat0, lon0, alt0, angleUnit); + [x0, y0, z0] = geodetic2ecef (E, lat0, lon0, alt0, angleUnit); [e, n, u] = ecef2enuv (x - x0, y - y0, z - z0, lat0, lon0, angleUnit); endfunction |