Skip to content

Commit

Permalink
add *2ned functions, use function-based tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Oct 12, 2020
1 parent 0314d3c commit 985480c
Show file tree
Hide file tree
Showing 14 changed files with 430 additions and 223 deletions.
197 changes: 0 additions & 197 deletions +matmap3d/+tests/test_unit.m

This file was deleted.

2 changes: 1 addition & 1 deletion +matmap3d/aer2ecef.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

end
%%
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
% Copyright (c) 2020 Michael Hirsch
% Copyright (c) 2013, Felipe Geremia Nievinski
%
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion +matmap3d/aer2enu.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

end
%%
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
% Copyright (c) 2020 Michael Hirsch
% Copyright (c) 2013, Felipe Geremia Nievinski
%
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion +matmap3d/aer2geodetic.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

end
%%
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
% Copyright (c) 2020 Michael Hirsch
% Copyright (c) 2013, Felipe Geremia Nievinski
%
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
31 changes: 31 additions & 0 deletions +matmap3d/aer2ned.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function [north, east, down] = aer2ned (az, el, slantRange, angleUnit)
%% aer2ned convert azimuth, elevation, range to NED coordinates
%
%%% Inputs
% * az, el, slantrange: look angles and distance to point under test (degrees, degrees, meters)
% * az: azimuth clockwise from local north
% * el: elevation angle above local horizon
% * angleUnit: string for angular units. Default 'd': degrees
%
%%% Outputs
% * north, east, down: coordinates of points (meters)
arguments
az {mustBeNumeric,mustBeReal}
el {mustBeNumeric,mustBeReal}
slantRange {mustBeNumeric,mustBeReal}
angleUnit (1,1) string = "d"
end

[east, north, up] = matmap3d.aer2enu(az, el, slantRange, angleUnit);

down = -up;

end
%%
% Copyright (c) 2020 Michael Hirsch
% Copyright (c) 2013, Felipe Geremia Nievinski
%
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
% 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
% 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11 changes: 6 additions & 5 deletions +matmap3d/ecef2enu.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function [e,n,u] = ecef2enu (x, y, z, lat0, lon0, alt0, spheroid, angleUnit)
%% ecef2enu convert ECEF to ENU
function [east, north, up] = ecef2enu (x, y, z, lat0, lon0, alt0, spheroid, angleUnit)
%% ecef2ned convert ECEF to NED
%
%%% Inputs
% * x,y,z: Earth Centered Earth Fixed (ECEF) coordinates of test point (meters)
Expand All @@ -8,7 +8,7 @@
% * angleUnit: string for angular units. Default 'd': degrees
%
%%% outputs
% * e,n,u: East, North, Up coordinates of test points (meters)
% * East, North, Up coordinates of test points (meters)
arguments
x {mustBeNumeric,mustBeReal}
y {mustBeNumeric,mustBeReal}
Expand All @@ -21,10 +21,11 @@
end

[x0, y0, z0] = matmap3d.geodetic2ecef(spheroid, lat0, lon0, alt0, angleUnit);
[e, n, u] = matmap3d.ecef2enuv(x - x0, y - y0, z - z0, lat0, lon0, angleUnit);
[east, north, up] = matmap3d.ecef2enuv(x - x0, y - y0, z - z0, lat0, lon0, angleUnit);

end
%%
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
% Copyright (c) 2020 Michael Hirsch
% Copyright (c) 2013, Felipe Geremia Nievinski
%
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion +matmap3d/ecef2geodetic.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

end % function
%%
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
% Copyright (c) 2020 Michael Hirsch
%
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
% 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Expand Down
36 changes: 36 additions & 0 deletions +matmap3d/ecef2ned.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function [north, east, down] = ecef2ned (x, y, z, lat0, lon0, alt0, spheroid, angleUnit)
%% ecef2enu convert ECEF to ENU
%
%%% Inputs
% * x,y,z: Earth Centered Earth Fixed (ECEF) coordinates of test point (meters)
% * lat0, lon0, alt0: ellipsoid geodetic coordinates of observer/reference (degrees, degrees, meters)
% * spheroid: referenceEllipsoid
% * angleUnit: string for angular units. Default 'd': degrees
%
%%% outputs
% * North,East,Down: coordinates of points (meters)

arguments
x {mustBeNumeric,mustBeReal}
y {mustBeNumeric,mustBeReal}
z {mustBeNumeric,mustBeReal}
lat0 {mustBeNumeric,mustBeReal}
lon0 {mustBeNumeric,mustBeReal}
alt0 {mustBeNumeric,mustBeReal}
spheroid (1,1) matmap3d.referenceEllipsoid = matmap3d.wgs84Ellipsoid()
angleUnit (1,1) string = "d"
end

[east, north, up] = ecef2enu(x,y,z,lat0,lon0,alt0,spheroid,angleUnit);

down = -up;

end
%%
% Copyright (c) 2020 Michael Hirsch
% Copyright (c) 2013, Felipe Geremia Nievinski
%
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
% 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
% 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 3 additions & 3 deletions +matmap3d/geodetic2enu.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [e, n, u] = geodetic2enu(lat, lon, alt, lat0, lon0, alt0, spheroid, angleUnit)
function [east, north, up] = geodetic2enu(lat, lon, alt, lat0, lon0, alt0, spheroid, angleUnit)
%% geodetic2enu convert from geodetic to ENU coordinates
%
%%% Inputs
Expand All @@ -8,7 +8,7 @@
% * angleUnit: string for angular units. Default 'd': degrees
%
%%% outputs
% * e,n,u: East, North, Up coordinates of test points (meters)
% * east,north,up: coordinates of points (meters)
arguments
lat {mustBeNumeric,mustBeReal}
lon {mustBeNumeric,mustBeReal}
Expand All @@ -27,7 +27,7 @@
dy = y1-y2;
dz = z1-z2;

[e, n, u] = matmap3d.ecef2enuv(dx, dy, dz, lat0, lon0, angleUnit);
[east, north, up] = matmap3d.ecef2enuv(dx, dy, dz, lat0, lon0, angleUnit);

end
%%
Expand Down
Loading

0 comments on commit 985480c

Please sign in to comment.