|
3 | 3 | properties |
4 | 4 | atol = 1e-9 |
5 | 5 | rtol = 1e-6 |
6 | | -E = matmap3d.wgs84Ellipsoid() |
7 | 6 | angleUnit='d' |
8 | 7 | lat = 42 |
9 | 8 | lon = -82 |
|
34 | 33 | methods(Test) |
35 | 34 |
|
36 | 35 | function test_ellipsoid(tc) |
37 | | -tc.verifyClass(tc.E, 'matmap3d.referenceEllipsoid') |
| 36 | +tc.verifyClass(matmap3d.wgs84Ellipsoid(), 'matmap3d.referenceEllipsoid') |
38 | 37 | end |
39 | 38 |
|
40 | 39 | function test_geodetic2ecef(tc) |
41 | 40 |
|
42 | | -[x,y,z] = matmap3d.geodetic2ecef(tc.E, tc.lat, tc.lon, tc.alt, tc.angleUnit); |
| 41 | +E = matmap3d.wgs84Ellipsoid(); |
| 42 | + |
| 43 | +[x,y,z] = matmap3d.geodetic2ecef(E, tc.lat, tc.lon, tc.alt, tc.angleUnit); |
43 | 44 | tc.verifyEqual([x,y,z], [tc.x0, tc.y0, tc.z0], AbsTol=tc.atol, RelTol=tc.rtol) |
44 | 45 |
|
45 | 46 | [x,y,z] = matmap3d.geodetic2ecef([], 0,0,-1); |
46 | | -tc.verifyEqual([x,y,z], [tc.E.SemimajorAxis-1,0,0], AbsTol=tc.atol, RelTol=tc.rtol) |
| 47 | +tc.verifyEqual([x,y,z], [E.SemimajorAxis-1,0,0], AbsTol=tc.atol, RelTol=tc.rtol) |
47 | 48 |
|
48 | | -[x,y,z] = matmap3d.geodetic2ecef(tc.E, 0,90,-1); |
49 | | -tc.verifyEqual([x,y,z], [0, tc.E.SemimajorAxis-1,0], AbsTol=tc.atol, RelTol=tc.rtol) |
| 49 | +[x,y,z] = matmap3d.geodetic2ecef(E, 0,90,-1); |
| 50 | +tc.verifyEqual([x,y,z], [0, E.SemimajorAxis-1,0], AbsTol=tc.atol, RelTol=tc.rtol) |
50 | 51 |
|
51 | | -[x,y,z] = matmap3d.geodetic2ecef(tc.E, 0,-90,-1); |
52 | | -tc.verifyEqual([x,y,z], [0, -tc.E.SemimajorAxis+1,0], AbsTol=tc.atol, RelTol=tc.rtol) |
| 52 | +[x,y,z] = matmap3d.geodetic2ecef(E, 0,-90,-1); |
| 53 | +tc.verifyEqual([x,y,z], [0, -E.SemimajorAxis+1,0], AbsTol=tc.atol, RelTol=tc.rtol) |
53 | 54 |
|
54 | | -[x,y,z] = matmap3d.geodetic2ecef(tc.E, 90,0,-1); |
55 | | -tc.verifyEqual([x,y,z], [0,0,tc.E.SemiminorAxis-1], AbsTol=tc.atol, RelTol=tc.rtol) |
| 55 | +[x,y,z] = matmap3d.geodetic2ecef(E, 90,0,-1); |
| 56 | +tc.verifyEqual([x,y,z], [0, 0, E.SemiminorAxis-1], AbsTol=tc.atol, RelTol=tc.rtol) |
56 | 57 |
|
57 | | -[x,y,z] = matmap3d.geodetic2ecef(tc.E, 90,15,-1); |
58 | | -tc.verifyEqual([x,y,z], [0,0,tc.E.SemiminorAxis-1], AbsTol=tc.atol, RelTol=tc.rtol) |
| 58 | +[x,y,z] = matmap3d.geodetic2ecef(E, 90,15,-1); |
| 59 | +tc.verifyEqual([x,y,z], [0,0, E.SemiminorAxis-1], AbsTol=tc.atol, RelTol=tc.rtol) |
59 | 60 |
|
60 | | -[x,y,z] = matmap3d.geodetic2ecef(tc.E, -90,0,-1); |
61 | | -tc.verifyEqual([x,y,z], [0,0,-tc.E.SemiminorAxis+1], AbsTol=tc.atol, RelTol=tc.rtol) |
| 61 | +[x,y,z] = matmap3d.geodetic2ecef(E, -90,0,-1); |
| 62 | +tc.verifyEqual([x,y,z], [0,0, -E.SemiminorAxis+1], AbsTol=tc.atol, RelTol=tc.rtol) |
62 | 63 |
|
63 | 64 | end |
64 | 65 |
|
65 | 66 | function test_ecef2geodetic(tc) |
66 | 67 |
|
67 | | -ea = tc.E.SemimajorAxis; |
68 | | -eb = tc.E.SemiminorAxis; |
| 68 | +E = matmap3d.wgs84Ellipsoid(); |
| 69 | + |
| 70 | +ea = E.SemimajorAxis; |
| 71 | +eb = E.SemiminorAxis; |
69 | 72 |
|
70 | | -[lt, ln, at] = matmap3d.ecef2geodetic(tc.E, tc.x0, tc.y0, tc.z0, tc.angleUnit); |
| 73 | +[lt, ln, at] = matmap3d.ecef2geodetic(E, tc.x0, tc.y0, tc.z0, tc.angleUnit); |
71 | 74 | tc.verifyEqual([lt, ln, at], [tc.lat, tc.lon, tc.alt], AbsTol=tc.atol, RelTol=tc.rtol) |
72 | 75 |
|
73 | 76 | [lt, ln, at] = matmap3d.ecef2geodetic([], ea-1, 0, 0); |
74 | 77 | tc.verifyEqual([lt, ln, at], [0, 0, -1], AbsTol=tc.atol, RelTol=tc.rtol) |
75 | 78 |
|
76 | | -[lt, ln, at] = matmap3d.ecef2geodetic(tc.E, 0, ea-1, 0); |
| 79 | +[lt, ln, at] = matmap3d.ecef2geodetic(E, 0, ea-1, 0); |
77 | 80 | tc.verifyEqual([lt, ln, at], [0, 90, -1], AbsTol=tc.atol, RelTol=tc.rtol) |
78 | 81 |
|
79 | | -[lt, ln, at] = matmap3d.ecef2geodetic(tc.E, 0, 0, eb-1); |
| 82 | +[lt, ln, at] = matmap3d.ecef2geodetic(E, 0, 0, eb-1); |
80 | 83 | tc.verifyEqual([lt, ln, at], [90, 0, -1], AbsTol=tc.atol, RelTol=tc.rtol) |
81 | 84 |
|
82 | | -[lt, ln, at] = matmap3d.ecef2geodetic(tc.E, 0, 0, -eb+1); |
| 85 | +[lt, ln, at] = matmap3d.ecef2geodetic(E, 0, 0, -eb+1); |
83 | 86 | tc.verifyEqual([lt, ln, at], [-90, 0, -1], AbsTol=tc.atol, RelTol=tc.rtol) |
84 | 87 |
|
85 | | -[lt, ln, at] = matmap3d.ecef2geodetic(tc.E, -ea+1, 0, 0); |
| 88 | +[lt, ln, at] = matmap3d.ecef2geodetic(E, -ea+1, 0, 0); |
86 | 89 | tc.verifyEqual([lt, ln, at], [0, 180, -1], AbsTol=tc.atol, RelTol=tc.rtol) |
87 | 90 |
|
88 | | -[lt, ln, at] = matmap3d.ecef2geodetic(tc.E, (ea-1000)/sqrt(2), (ea-1000)/sqrt(2), 0); |
| 91 | +[lt, ln, at] = matmap3d.ecef2geodetic(E, (ea-1000)/sqrt(2), (ea-1000)/sqrt(2), 0); |
89 | 92 | tc.verifyEqual([lt,ln,at], [0,45,-1000], AbsTol=tc.atol, RelTol=tc.rtol) |
90 | 93 |
|
91 | 94 | end |
@@ -113,66 +116,74 @@ function test_aer2enu(tc) |
113 | 116 |
|
114 | 117 | function test_ecef2aer(tc) |
115 | 118 |
|
116 | | -[a, e, r] = matmap3d.ecef2aer(tc.xl, tc.yl, tc.zl, tc.lat, tc.lon, tc.alt, tc.E, tc.angleUnit); |
| 119 | +E = matmap3d.wgs84Ellipsoid(); |
| 120 | + |
| 121 | +[a, e, r] = matmap3d.ecef2aer(tc.xl, tc.yl, tc.zl, tc.lat, tc.lon, tc.alt, E, tc.angleUnit); |
117 | 122 | % round-trip |
118 | 123 | tc.verifyEqual([a,e,r], [tc.az, tc.el, tc.srange], AbsTol=tc.atol, RelTol=tc.rtol) |
119 | 124 |
|
120 | 125 | % singularity check |
121 | | -[a, e, r] = matmap3d.ecef2aer(tc.E.SemimajorAxis-1, 0, 0, 0,0,0, tc.E, tc.angleUnit); |
| 126 | +[a, e, r] = matmap3d.ecef2aer(E.SemimajorAxis-1, 0, 0, 0,0,0, E, tc.angleUnit); |
122 | 127 | tc.verifyEqual([a,e,r], [0, -tc.a90, 1], AbsTol=tc.atol, RelTol=tc.rtol) |
123 | 128 |
|
124 | | -[a, e, r] = matmap3d.ecef2aer(-tc.E.SemimajorAxis+1, 0, 0, 0, 2*tc.a90,0, tc.E, tc.angleUnit); |
| 129 | +[a, e, r] = matmap3d.ecef2aer(-E.SemimajorAxis+1, 0, 0, 0, 2*tc.a90,0, E, tc.angleUnit); |
125 | 130 | tc.verifyEqual([a,e,r], [0, -tc.a90, 1], AbsTol=tc.atol, RelTol=tc.rtol) |
126 | 131 |
|
127 | | -[a, e, r] = matmap3d.ecef2aer(0, tc.E.SemimajorAxis-1, 0,0, tc.a90,0, tc.E, tc.angleUnit); |
| 132 | +[a, e, r] = matmap3d.ecef2aer(0, E.SemimajorAxis-1, 0,0, tc.a90,0, E, tc.angleUnit); |
128 | 133 | tc.verifyEqual([a,e,r], [0, -tc.a90, 1], AbsTol=tc.atol, RelTol=tc.rtol) |
129 | 134 |
|
130 | | -[a, e, r] = matmap3d.ecef2aer(0, -tc.E.SemimajorAxis+1, 0,0, -tc.a90,0, tc.E, tc.angleUnit); |
| 135 | +[a, e, r] = matmap3d.ecef2aer(0, -E.SemimajorAxis+1, 0,0, -tc.a90,0, E, tc.angleUnit); |
131 | 136 | tc.verifyEqual([a,e,r], [0, -tc.a90, 1], AbsTol=tc.atol, RelTol=tc.rtol) |
132 | 137 |
|
133 | | -[a, e, r] = matmap3d.ecef2aer(0, 0, tc.E.SemiminorAxis-1, tc.a90, 0, 0, tc.E, tc.angleUnit); |
| 138 | +[a, e, r] = matmap3d.ecef2aer(0, 0, E.SemiminorAxis-1, tc.a90, 0, 0, E, tc.angleUnit); |
134 | 139 | tc.verifyEqual([a,e,r], [0, -tc.a90, 1], AbsTol=tc.atol, RelTol=tc.rtol) |
135 | 140 |
|
136 | | -[a, e, r] = matmap3d.ecef2aer(0, 0, -tc.E.SemiminorAxis+1,-tc.a90,0,0, tc.E, tc.angleUnit); |
| 141 | +[a, e, r] = matmap3d.ecef2aer(0, 0, -E.SemiminorAxis+1,-tc.a90,0,0, E, tc.angleUnit); |
137 | 142 | tc.verifyEqual([a,e,r], [0, -tc.a90, 1], AbsTol=tc.atol, RelTol=tc.rtol) |
138 | 143 |
|
139 | | -[a, e, r] = matmap3d.ecef2aer((tc.E.SemimajorAxis-1000)/sqrt(2), (tc.E.SemimajorAxis-1000)/sqrt(2), 0, 0, 45, 0); |
| 144 | +[a, e, r] = matmap3d.ecef2aer((E.SemimajorAxis-1000)/sqrt(2), (E.SemimajorAxis-1000)/sqrt(2), 0, 0, 45, 0); |
140 | 145 | tc.verifyEqual([a,e,r],[0,-90,1000], AbsTol=tc.atol, RelTol=tc.rtol) |
141 | 146 |
|
142 | | -[x,y,z] = matmap3d.aer2ecef(tc.az, tc.el, tc.srange, tc.lat, tc.lon, tc.alt,tc.E, tc.angleUnit); |
| 147 | +[x,y,z] = matmap3d.aer2ecef(tc.az, tc.el, tc.srange, tc.lat, tc.lon, tc.alt, E, tc.angleUnit); |
143 | 148 | tc.verifyEqual([x,y,z], [tc.xl, tc.yl, tc.zl], AbsTol=tc.atol, RelTol=tc.rtol) |
144 | 149 |
|
145 | | -[a,e,r] = matmap3d.ecef2aer(x,y,z, tc.lat, tc.lon, tc.alt, tc.E, tc.angleUnit); |
| 150 | +[a,e,r] = matmap3d.ecef2aer(x,y,z, tc.lat, tc.lon, tc.alt, E, tc.angleUnit); |
146 | 151 | tc.verifyEqual([a,e,r], [tc.az, tc.el, tc.srange], AbsTol=tc.atol, RelTol=tc.rtol) |
147 | 152 | end |
148 | 153 |
|
149 | 154 | function test_geodetic2aer(tc) |
150 | 155 |
|
151 | | -[lt,ln,at] = matmap3d.aer2geodetic(tc.az, tc.el, tc.srange, tc.lat, tc.lon, tc.alt, tc.E, tc.angleUnit); |
| 156 | +E = matmap3d.wgs84Ellipsoid(); |
| 157 | + |
| 158 | +[lt,ln,at] = matmap3d.aer2geodetic(tc.az, tc.el, tc.srange, tc.lat, tc.lon, tc.alt, E, tc.angleUnit); |
152 | 159 | tc.verifyEqual([lt,ln,at], [tc.lat1, tc.lon1, tc.alt1], AbsTol=2*tc.atol_dist) |
153 | 160 |
|
154 | | -[a, e, r] = matmap3d.geodetic2aer(lt,ln,at, tc.lat, tc.lon, tc.alt, tc.E, tc.angleUnit); % round-trip |
| 161 | +[a, e, r] = matmap3d.geodetic2aer(lt,ln,at, tc.lat, tc.lon, tc.alt, E, tc.angleUnit); % round-trip |
155 | 162 | tc.verifyEqual([a,e,r], [tc.az, tc.el, tc.srange], AbsTol=tc.atol, RelTol=tc.rtol) |
156 | 163 | end |
157 | 164 |
|
158 | 165 | function test_geodetic2enu(tc) |
159 | 166 |
|
160 | | -[e, n, u] = matmap3d.geodetic2enu(tc.lat, tc.lon, tc.alt-1, tc.lat, tc.lon, tc.alt, tc.E, tc.angleUnit); |
| 167 | +E = matmap3d.wgs84Ellipsoid(); |
| 168 | + |
| 169 | +[e, n, u] = matmap3d.geodetic2enu(tc.lat, tc.lon, tc.alt-1, tc.lat, tc.lon, tc.alt, E, tc.angleUnit); |
161 | 170 | tc.verifyEqual([e,n,u], [0,0,-1], AbsTol=tc.atol, RelTol=tc.rtol) |
162 | 171 |
|
163 | | -[lt, ln, at] = matmap3d.enu2geodetic(e,n,u,tc.lat,tc.lon,tc.alt, tc.E, tc.angleUnit); % round-trip |
| 172 | +[lt, ln, at] = matmap3d.enu2geodetic(e,n,u,tc.lat,tc.lon,tc.alt, E, tc.angleUnit); % round-trip |
164 | 173 | tc.verifyEqual([lt, ln, at],[tc.lat, tc.lon, tc.alt-1], AbsTol=tc.atol, RelTol=tc.rtol) |
165 | 174 | end |
166 | 175 |
|
167 | 176 | function test_enu2ecef(tc) |
168 | 177 |
|
169 | | -[x, y, z] = matmap3d.enu2ecef(tc.er, tc.nr, tc.ur, tc.lat,tc.lon,tc.alt, tc.E, tc.angleUnit); |
| 178 | +E = matmap3d.wgs84Ellipsoid(); |
| 179 | + |
| 180 | +[x, y, z] = matmap3d.enu2ecef(tc.er, tc.nr, tc.ur, tc.lat,tc.lon,tc.alt, E, tc.angleUnit); |
170 | 181 | tc.verifyEqual([x,y,z],[tc.xl, tc.yl, tc.zl], AbsTol=tc.atol, RelTol=tc.rtol) |
171 | 182 |
|
172 | | -[e,n,u] = matmap3d.ecef2enu(x,y,z,tc.lat,tc.lon,tc.alt, tc.E, tc.angleUnit); % round-trip |
| 183 | +[e,n,u] = matmap3d.ecef2enu(x,y,z,tc.lat,tc.lon,tc.alt, E, tc.angleUnit); % round-trip |
173 | 184 | tc.verifyEqual([e,n,u],[tc.er, tc.nr, tc.ur], AbsTol=tc.atol, RelTol=tc.rtol) |
174 | 185 |
|
175 | | -[n1, e1, d] = matmap3d.ecef2ned(x,y,z,tc.lat,tc.lon,tc.alt, tc.E, tc.angleUnit); |
| 186 | +[n1, e1, d] = matmap3d.ecef2ned(x,y,z,tc.lat,tc.lon,tc.alt, E, tc.angleUnit); |
176 | 187 | tc.verifyEqual([e,n,u],[e1,n1,-d]) |
177 | 188 | end |
178 | 189 |
|
@@ -211,6 +222,15 @@ function test_ecef2eci(tc) |
211 | 222 | tc.verifyEqual(r_eci, [-2981829.07728415; 5207029.04470791; 3161595.0981204], RelTol=1e-5) |
212 | 223 | end |
213 | 224 |
|
| 225 | +function test_ecef2eci_null(tc) |
| 226 | +E = matmap3d.wgs84Ellipsoid(); |
| 227 | + |
| 228 | +[x, y, z] = matmap3d.geodetic2ecef(E, 0, 0, 0); |
| 229 | +t = datetime(2000, 1, 1, 12, 0, 0, TimeZone='UTCLeapSeconds'); |
| 230 | +r_eci = matmap3d.ecef2eci(t, [x;y;z]); |
| 231 | +tc.verifyEqual(r_eci, [1158174.72525987; -6272101.9503871; -143.138407305876], RelTol=tc.rtol) |
| 232 | +end |
| 233 | + |
214 | 234 |
|
215 | 235 | function test_eci2aer(tc) |
216 | 236 | eci = [-3.8454e8, -0.5099e8, -0.3255e8]; |
|
0 commit comments