summaryrefslogtreecommitdiff
path: root/inst/geodetic2ned.m
diff options
context:
space:
mode:
Diffstat (limited to 'inst/geodetic2ned.m')
-rw-r--r--inst/geodetic2ned.m25
1 files changed, 11 insertions, 14 deletions
diff --git a/inst/geodetic2ned.m b/inst/geodetic2ned.m
index 214fef7..8c60699 100644
--- a/inst/geodetic2ned.m
+++ b/inst/geodetic2ned.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:
@@ -46,7 +46,7 @@
## geoid and the WGS84 reference ellipsoid.
##
## @item
-## @var{spheroid} (optional): a user-specified sheroid (see referenceEllipsoid);
+## @var{spheroid} (optional): a user-specified spheroid (see referenceEllipsoid);
## it can be omitted or given as an empty string or empty numeric array('[]'),
## in which cases WGS84 will be selected as default spheroid.
##
@@ -74,7 +74,7 @@
## u = -799.99
## @end example
##
-## @seealso {ned2geodetic, geodetic2aer, geodetic2ecef, geodetic2enu,
+## @seealso{ned2geodetic, geodetic2aer, geodetic2ecef, geodetic2enu,
## egm96geoid, referenceEllipsoid}
## @end deftypefn
@@ -125,13 +125,10 @@ function [n, e, d] = geodetic2ned (varargin)
error ("geodetic2ned: non-matching dimensions of ECEF inputs.");
endif
- if (isempty (spheroid))
- E = wgs84Ellipsoid;
- elseif (isstruct (spheroid))
- E = spheroid;
- else
- E = referenceEllipsoid (spheroid);
+ if (isnumeric (spheroid))
+ spheroid = num2str (spheroid);
endif
+ E = sph_chk (spheroid);
if (! ischar (angleUnit) || ! ismember (lower (angleUnit(1)), {"d", "r"}))
error ("geodetic2ned: angleUnit should be one of 'degrees' or 'radians'")
@@ -140,9 +137,9 @@ function [n, e, d] = geodetic2ned (varargin)
[x1, y1, z1] = geodetic2ecef (E, lat, lon, alt, angleUnit);
[x2, y2, z2] = geodetic2ecef (E, lat0, lon0, alt0, angleUnit);
- dx = x1 .- x2;
- dy = y1 .- y2;
- dz = z1 .- z2;
+ dx = x1 - x2;
+ dy = y1 - y2;
+ dz = z1 - z2;
[n, e, d] = ecef2nedv (dx, dy, dz, lat0, lon0, angleUnit);