Skip to content

Commit 985480c

Browse files
committed
add *2ned functions, use function-based tests
1 parent 0314d3c commit 985480c

14 files changed

+430
-223
lines changed

+matmap3d/+tests/test_unit.m

Lines changed: 0 additions & 197 deletions
This file was deleted.

+matmap3d/aer2ecef.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
end
4040
%%
41-
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
41+
% Copyright (c) 2020 Michael Hirsch
4242
% Copyright (c) 2013, Felipe Geremia Nievinski
4343
%
4444
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+matmap3d/aer2enu.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
end
3131
%%
32-
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
32+
% Copyright (c) 2020 Michael Hirsch
3333
% Copyright (c) 2013, Felipe Geremia Nievinski
3434
%
3535
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+matmap3d/aer2geodetic.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
end
3030
%%
31-
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
31+
% Copyright (c) 2020 Michael Hirsch
3232
% Copyright (c) 2013, Felipe Geremia Nievinski
3333
%
3434
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+matmap3d/aer2ned.m

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function [north, east, down] = aer2ned (az, el, slantRange, angleUnit)
2+
%% aer2ned convert azimuth, elevation, range to NED coordinates
3+
%
4+
%%% Inputs
5+
% * az, el, slantrange: look angles and distance to point under test (degrees, degrees, meters)
6+
% * az: azimuth clockwise from local north
7+
% * el: elevation angle above local horizon
8+
% * angleUnit: string for angular units. Default 'd': degrees
9+
%
10+
%%% Outputs
11+
% * north, east, down: coordinates of points (meters)
12+
arguments
13+
az {mustBeNumeric,mustBeReal}
14+
el {mustBeNumeric,mustBeReal}
15+
slantRange {mustBeNumeric,mustBeReal}
16+
angleUnit (1,1) string = "d"
17+
end
18+
19+
[east, north, up] = matmap3d.aer2enu(az, el, slantRange, angleUnit);
20+
21+
down = -up;
22+
23+
end
24+
%%
25+
% Copyright (c) 2020 Michael Hirsch
26+
% Copyright (c) 2013, Felipe Geremia Nievinski
27+
%
28+
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
29+
% 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
30+
% 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.
31+
% 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.

+matmap3d/ecef2enu.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function [e,n,u] = ecef2enu (x, y, z, lat0, lon0, alt0, spheroid, angleUnit)
2-
%% ecef2enu convert ECEF to ENU
1+
function [east, north, up] = ecef2enu (x, y, z, lat0, lon0, alt0, spheroid, angleUnit)
2+
%% ecef2ned convert ECEF to NED
33
%
44
%%% Inputs
55
% * x,y,z: Earth Centered Earth Fixed (ECEF) coordinates of test point (meters)
@@ -8,7 +8,7 @@
88
% * angleUnit: string for angular units. Default 'd': degrees
99
%
1010
%%% outputs
11-
% * e,n,u: East, North, Up coordinates of test points (meters)
11+
% * East, North, Up coordinates of test points (meters)
1212
arguments
1313
x {mustBeNumeric,mustBeReal}
1414
y {mustBeNumeric,mustBeReal}
@@ -21,10 +21,11 @@
2121
end
2222

2323
[x0, y0, z0] = matmap3d.geodetic2ecef(spheroid, lat0, lon0, alt0, angleUnit);
24-
[e, n, u] = matmap3d.ecef2enuv(x - x0, y - y0, z - z0, lat0, lon0, angleUnit);
24+
[east, north, up] = matmap3d.ecef2enuv(x - x0, y - y0, z - z0, lat0, lon0, angleUnit);
25+
2526
end
2627
%%
27-
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
28+
% Copyright (c) 2020 Michael Hirsch
2829
% Copyright (c) 2013, Felipe Geremia Nievinski
2930
%
3031
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+matmap3d/ecef2geodetic.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
end % function
6969
%%
70-
% Copyright (c) 2014-2018 Michael Hirsch, Ph.D.
70+
% Copyright (c) 2020 Michael Hirsch
7171
%
7272
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7373
% 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

+matmap3d/ecef2ned.m

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function [north, east, down] = ecef2ned (x, y, z, lat0, lon0, alt0, spheroid, angleUnit)
2+
%% ecef2enu convert ECEF to ENU
3+
%
4+
%%% Inputs
5+
% * x,y,z: Earth Centered Earth Fixed (ECEF) coordinates of test point (meters)
6+
% * lat0, lon0, alt0: ellipsoid geodetic coordinates of observer/reference (degrees, degrees, meters)
7+
% * spheroid: referenceEllipsoid
8+
% * angleUnit: string for angular units. Default 'd': degrees
9+
%
10+
%%% outputs
11+
% * North,East,Down: coordinates of points (meters)
12+
13+
arguments
14+
x {mustBeNumeric,mustBeReal}
15+
y {mustBeNumeric,mustBeReal}
16+
z {mustBeNumeric,mustBeReal}
17+
lat0 {mustBeNumeric,mustBeReal}
18+
lon0 {mustBeNumeric,mustBeReal}
19+
alt0 {mustBeNumeric,mustBeReal}
20+
spheroid (1,1) matmap3d.referenceEllipsoid = matmap3d.wgs84Ellipsoid()
21+
angleUnit (1,1) string = "d"
22+
end
23+
24+
[east, north, up] = ecef2enu(x,y,z,lat0,lon0,alt0,spheroid,angleUnit);
25+
26+
down = -up;
27+
28+
end
29+
%%
30+
% Copyright (c) 2020 Michael Hirsch
31+
% Copyright (c) 2013, Felipe Geremia Nievinski
32+
%
33+
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
34+
% 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
35+
% 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.
36+
% 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.

+matmap3d/geodetic2enu.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [e, n, u] = geodetic2enu(lat, lon, alt, lat0, lon0, alt0, spheroid, angleUnit)
1+
function [east, north, up] = geodetic2enu(lat, lon, alt, lat0, lon0, alt0, spheroid, angleUnit)
22
%% geodetic2enu convert from geodetic to ENU coordinates
33
%
44
%%% Inputs
@@ -8,7 +8,7 @@
88
% * angleUnit: string for angular units. Default 'd': degrees
99
%
1010
%%% outputs
11-
% * e,n,u: East, North, Up coordinates of test points (meters)
11+
% * east,north,up: coordinates of points (meters)
1212
arguments
1313
lat {mustBeNumeric,mustBeReal}
1414
lon {mustBeNumeric,mustBeReal}
@@ -27,7 +27,7 @@
2727
dy = y1-y2;
2828
dz = z1-z2;
2929

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

3232
end
3333
%%

0 commit comments

Comments
 (0)