1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.models.earth;
18
19 import static org.hamcrest.CoreMatchers.is;
20 import static org.hamcrest.MatcherAssert.assertThat;
21 import static org.hipparchus.util.FastMath.PI;
22 import static org.hipparchus.util.FastMath.abs;
23 import static org.junit.Assert.assertEquals;
24 import static org.orekit.OrekitMatchers.relativelyCloseTo;
25
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.orekit.forces.gravity.potential.GravityFieldFactory;
29 import org.orekit.frames.Frame;
30 import org.orekit.frames.FramesFactory;
31 import org.orekit.utils.Constants;
32
33
34
35
36
37
38
39 public class ReferenceEllipsoidTest {
40
41
42
43 @Test
44 public void testReferenceEllipsoid() {
45 double a = 1, f = 0.5, gm = 2, omega = 3;
46 ReferenceEllipsoid ellipsoid = new ReferenceEllipsoid(a, f,
47 FramesFactory.getGCRF(), gm, omega);
48 assertThat(ellipsoid.getEquatorialRadius(), is(a));
49 assertThat(ellipsoid.getFlattening(), is(f));
50 assertThat(ellipsoid.getGM(), is(gm));
51 assertThat(ellipsoid.getSpin(), is(omega));
52 }
53
54
55
56
57
58
59
60
61 private ReferenceEllipsoid getComponent() {
62
63
64
65
66 double a = 6378137.00, f = 1 / 298.257223563, GM = 3.986004418e14, spin = 7292115e-11;
67 return new ReferenceEllipsoid(a, f, FramesFactory.getGCRF(), GM, spin);
68 }
69
70
71
72
73
74 @Test
75 public void testGetNormalGravity() {
76 ReferenceEllipsoid ellipsoid = getComponent();
77
78
79 double[] lat = {-90, -45, 0, 45, 90};
80
81 double[] expected = {9.833276738917813685281,
82 9.8064684244573317502963, 9.779777598918278489352,
83 9.8064684244573317502963, 9.833276738917813685281};
84
85
86 assertEquals(lat.length, expected.length);
87 for (int i = 0; i < expected.length; i++) {
88 assertThat(ellipsoid.getNormalGravity(lat[i] * PI / 180.),
89 relativelyCloseTo(expected[i], 1));
90 }
91 }
92
93
94 @Test
95 public void testGetC2n0() {
96 ReferenceEllipsoid ellipsoid = getComponent();
97
98
99
100
101 double expected = -0.484166774985e-3;
102
103
104 Assert.assertEquals(
105 "J2 term\n", ellipsoid.getC2n0(1), expected, 1.31e-9);
106
107
108
109
110 double[] expecteds = {7.90304054e-7, -1.687251e-9, 3.461e-12};
111 for (int i = 0; i < expecteds.length; i++) {
112 double C2n = ellipsoid.getC2n0(2 + i);
113 expected = expecteds[i];
114
115 Assert.assertEquals("C" + (4 + 2 * i) + ",0" + "\n",
116 C2n, expected, abs(2e-4 * expected));
117 }
118 }
119
120
121 @Test(expected = IllegalArgumentException.class)
122 public void testGetC2n0Bad() {
123 getComponent().getC2n0(0);
124 }
125
126
127 @Test
128 public void testGetPolarRadius() {
129 assertThat(getComponent().getPolarRadius(), is(6356752.314245179));
130 }
131
132
133
134
135 @Test
136 public void testGetWgs84() {
137
138 double c20factor = GravityFieldFactory.getUnnormalizationFactors(2, 0)[2][0];
139 Frame frame = FramesFactory.getGCRF();
140
141
142 ReferenceEllipsoid wgs84 = ReferenceEllipsoid.getWgs84(frame);
143
144
145 Assert.assertEquals(
146 wgs84.getC2n0(1), Constants.WGS84_EARTH_C20 / c20factor, 3e-9);
147 assertThat(wgs84.getBodyFrame(), is(frame));
148 }
149
150
151
152
153 @Test
154 public void testGetGrs80() {
155
156 double c20factor = GravityFieldFactory.getUnnormalizationFactors(2, 0)[2][0];
157 Frame frame = FramesFactory.getGCRF();
158
159
160 ReferenceEllipsoid grs80 = ReferenceEllipsoid.getGrs80(frame);
161
162
163 Assert.assertEquals(
164 grs80.getC2n0(1), Constants.GRS80_EARTH_C20 / c20factor, 3e-9);
165 assertThat(grs80.getBodyFrame(), is(frame));
166 }
167
168
169
170
171 @Test
172 public void testGetIers96() {
173
174 double c20factor = GravityFieldFactory.getUnnormalizationFactors(2, 0)[2][0];
175 Frame frame = FramesFactory.getGCRF();
176
177
178 ReferenceEllipsoid iers96 = ReferenceEllipsoid.getIers96(frame);
179
180
181 Assert.assertEquals(
182 iers96.getC2n0(1), Constants.IERS96_EARTH_C20 / c20factor, 3e-9);
183 assertThat(iers96.getBodyFrame(), is(frame));
184 }
185
186
187
188
189 @Test
190 public void testGetIers2003() {
191
192 double c20factor = GravityFieldFactory.getUnnormalizationFactors(2, 0)[2][0];
193 Frame frame = FramesFactory.getGCRF();
194
195
196 ReferenceEllipsoid iers2003 = ReferenceEllipsoid.getIers2003(frame);
197
198
199 Assert.assertEquals(
200 iers2003.getC2n0(1), Constants.IERS2003_EARTH_C20 / c20factor, 3e-9);
201 assertThat(iers2003.getBodyFrame(), is(frame));
202 }
203
204
205
206
207 @Test
208 public void testGetIers2010() {
209
210 double c20factor = GravityFieldFactory.getUnnormalizationFactors(2, 0)[2][0];
211 Frame frame = FramesFactory.getGCRF();
212
213
214 ReferenceEllipsoid iers2010 = ReferenceEllipsoid.getIers2010(frame);
215
216
217 Assert.assertEquals(
218 iers2010.getC2n0(1), Constants.IERS2010_EARTH_C20 / c20factor, 3e-9);
219 assertThat(iers2010.getBodyFrame(), is(frame));
220 }
221
222
223 @Test
224 public void testGetEllipsoid() {
225
226 ReferenceEllipsoid ellipsoid = getComponent();
227
228
229 assertThat(ellipsoid.getEllipsoid(), is(ellipsoid));
230 }
231 }