1 /* Contributed in the public domain.
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.models.earth;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.Field;
21 import org.hipparchus.analysis.CalculusFieldUnivariateFunction;
22 import org.hipparchus.analysis.UnivariateFunction;
23 import org.hipparchus.analysis.solvers.AllowedSolution;
24 import org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver;
25 import org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver;
26 import org.hipparchus.analysis.solvers.UnivariateSolver;
27 import org.hipparchus.exception.MathRuntimeException;
28 import org.hipparchus.geometry.euclidean.threed.FieldLine;
29 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
30 import org.hipparchus.geometry.euclidean.threed.Line;
31 import org.hipparchus.geometry.euclidean.threed.Vector3D;
32 import org.hipparchus.util.FastMath;
33 import org.orekit.bodies.FieldGeodeticPoint;
34 import org.orekit.bodies.GeodeticPoint;
35 import org.orekit.errors.OrekitException;
36 import org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel;
37 import org.orekit.forces.gravity.potential.GravityFields;
38 import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider;
39 import org.orekit.forces.gravity.potential.TideSystem;
40 import org.orekit.frames.FieldStaticTransform;
41 import org.orekit.frames.Frame;
42 import org.orekit.frames.StaticTransform;
43 import org.orekit.time.AbsoluteDate;
44 import org.orekit.time.FieldAbsoluteDate;
45 import org.orekit.utils.TimeStampedPVCoordinates;
46
47 /**
48 * A geoid is a level surface of the gravity potential of a body. The gravity
49 * potential, W, is split so W = U + T, where U is the normal potential (defined
50 * by the ellipsoid) and T is the anomalous potential.[3](eq. 2-137)
51 *
52 * <p> The {@link #getIntersectionPoint(Line, Vector3D, Frame, AbsoluteDate)}
53 * method is tailored specifically for Earth's geoid. All of the other methods
54 * in this class are general and will work for an arbitrary body.
55 *
56 * <p> There are several components that are needed to define a geoid[1]:
57 *
58 * <ul> <li>Geopotential field. These are the coefficients of the spherical
59 * harmonics: S<sub>n,m</sub> and C<sub>n,m</sub></li>
60 *
61 * <li>Reference Ellipsoid. The ellipsoid is used to define the undulation of
62 * the geoid (distance between ellipsoid and geoid) and U<sub>0</sub> the value
63 * of the normal gravity potential at the surface of the ellipsoid.</li>
64 *
65 * <li>W<sub>0</sub>, the potential at the geoid. The value of the potential on
66 * the level surface. This is taken to be U<sub>0</sub>, the normal gravity
67 * potential at the surface of the {@link ReferenceEllipsoid}.</li>
68 *
69 * <li>Permanent Tide System. This implementation assumes that the geopotential
70 * field and the reference ellipsoid use the same permanent tide system. If the
71 * assumption is false it will produce errors of about 0.5 m. Conversion between
72 * tide systems is a possible improvement.[1,2]</li>
73 *
74 * <li>Topographic Masses. That is mass outside of the geoid, e.g. mountains.
75 * This implementation ignores topographic masses, which causes up to 3m error
76 * in the Himalayas, and ~ 1.5m error in the Rockies. This could be improved
77 * through the use of DTED and calculating height anomalies or using the
78 * correction coefficients.[1]</li> </ul>
79 *
80 * <p> This implementation also assumes that the normal to the reference
81 * ellipsoid is the same as the normal to the geoid. This assumption enables the
82 * equation: (height above geoid) = (height above ellipsoid) - (undulation),
83 * which is used in {@link #transform(GeodeticPoint)} and {@link
84 * #transform(Vector3D, Frame, AbsoluteDate)}.
85 *
86 * <p> In testing, the error in the undulations calculated by this class were
87 * off by less than 3 meters, which matches the assumptions outlined above.
88 *
89 * <p> References:
90 *
91 * <ol> <li>Dru A. Smith. There is no such thing as "The" EGM96 geoid: Subtle
92 * points on the use of a global geopotential model. IGeS Bulletin No. 8:17-28,
93 * 1998. <a href= "http://www.ngs.noaa.gov/PUBS_LIB/EGM96_GEOID_PAPER/egm96_geoid_paper.html"
94 * >http://www.ngs.noaa.gov/PUBS_LIB/EGM96_GEOID_PAPER/egm96_geoid_paper.html</a></li>
95 *
96 * <li> Martin Losch, Verena Seufer. How to Compute Geoid Undulations (Geoid
97 * Height Relative to a Given Reference Ellipsoid) from Spherical Harmonic
98 * Coefficients for Satellite Altimetry Applications. , 2003. <a
99 * href="http://mitgcm.org/~mlosch/geoidcookbook.pdf">mitgcm.org/~mlosch/geoidcookbook.pdf</a>
100 * </li>
101 *
102 * <li>Weikko A. Heiskanen, Helmut Moritz. Physical Geodesy. W. H. Freeman and
103 * Company, 1967. (especially sections 2.13 and equation 2-144 Bruns
104 * Formula)</li>
105 *
106 * <li>S. A. Holmes, W. E. Featherstone. A unified approach to the Clenshaw
107 * summation and the recursive computation of very high degree and order
108 * normalised associated Legendre functions. Journal of Geodesy, 76(5):279,
109 * 2002.</li>
110 *
111 * <li>DMA TR 8350.2. 1984.</li>
112 *
113 * <li>Department of Defense World Geodetic System 1984. 2000. NIMA TR 8350.2
114 * Third Edition, Amendment 1.</li> </ol>
115 *
116 * @author Evan Ward
117 */
118 public class Geoid implements EarthShape {
119
120 /**
121 * A number larger than the largest undulation. Wikipedia says the geoid
122 * height is in [-106, 85]. I chose 100 to be safe.
123 */
124 private static final double MAX_UNDULATION = 100;
125 /**
126 * A number smaller than the smallest undulation. Wikipedia says the geoid
127 * height is in [-106, 85]. I chose -150 to be safe.
128 */
129 private static final double MIN_UNDULATION = -150;
130 /**
131 * the maximum number of evaluations for the line search in {@link
132 * #getIntersectionPoint(Line, Vector3D, Frame, AbsoluteDate)}.
133 */
134 private static final int MAX_EVALUATIONS = 100;
135
136 /**
137 * the default date to use when evaluating the {@link #harmonics}. Used when
138 * no other dates are available. Should be removed in a future release.
139 */
140 private final AbsoluteDate defaultDate;
141 /**
142 * the reference ellipsoid.
143 */
144 private final ReferenceEllipsoid referenceEllipsoid;
145 /**
146 * the geo-potential combined with an algorithm for evaluating the spherical
147 * harmonics. The Holmes and Featherstone method is very robust.
148 */
149 private final transient HolmesFeatherstoneAttractionModel harmonics;
150
151 /**
152 * Creates a geoid from the given geopotential, reference ellipsoid and the
153 * assumptions in the comment for {@link Geoid}.
154 *
155 * @param geopotential the gravity potential. Only the anomalous
156 * potential will be used. It is assumed that the
157 * {@code geopotential} and the {@code
158 * referenceEllipsoid} are defined in the same
159 * frame. Usually a {@link GravityFields#getConstantNormalizedProvider(int,
160 * int, AbsoluteDate) constant geopotential} is used to define a
161 * time-invariant Geoid.
162 * @param referenceEllipsoid the normal gravity potential.
163 * @throws NullPointerException if {@code geopotential == null ||
164 * referenceEllipsoid == null}
165 */
166 public Geoid(final NormalizedSphericalHarmonicsProvider geopotential,
167 final ReferenceEllipsoid referenceEllipsoid) {
168 // parameter check
169 if (geopotential == null || referenceEllipsoid == null) {
170 throw new NullPointerException();
171 }
172
173 // subtract the ellipsoid from the geopotential
174 final SubtractEllipsoid potential = new SubtractEllipsoid(geopotential,
175 referenceEllipsoid);
176
177 // set instance parameters
178 this.referenceEllipsoid = referenceEllipsoid;
179 this.harmonics = new HolmesFeatherstoneAttractionModel(
180 referenceEllipsoid.getBodyFrame(), potential);
181 this.defaultDate = AbsoluteDate.ARBITRARY_EPOCH;
182 }
183
184 @Override
185 public Frame getBodyFrame() {
186 // same as for reference ellipsoid.
187 return this.getEllipsoid().getBodyFrame();
188 }
189
190 /**
191 * Gets the Undulation of the Geoid, N at the given position. N is the
192 * distance between the {@link #getEllipsoid() reference ellipsoid} and the
193 * geoid. The latitude and longitude parameters are both defined with
194 * respect to the reference ellipsoid. For EGM96 and the WGS84 ellipsoid the
195 * undulation is between -107m and +86m.
196 *
197 * <p> NOTE: Restrictions are not put on the range of the arguments {@code
198 * geodeticLatitude} and {@code longitude}.
199 *
200 * @param geodeticLatitude geodetic latitude (angle between the local normal
201 * and the equatorial plane on the reference
202 * ellipsoid), in radians.
203 * @param longitude on the reference ellipsoid, in radians.
204 * @param date of evaluation. Used for time varying geopotential
205 * fields.
206 * @return the undulation in m, positive means the geoid is higher than the
207 * ellipsoid.
208 * @see Geoid
209 * @see <a href="http://en.wikipedia.org/wiki/Geoid">Geoid on Wikipedia</a>
210 */
211 public double getUndulation(final double geodeticLatitude,
212 final double longitude,
213 final AbsoluteDate date) {
214 /*
215 * equations references are to the algorithm printed in the geoid
216 * cookbook[2]. See comment for Geoid.
217 */
218 // reference ellipsoid
219 final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
220
221 // position in geodetic coordinates
222 final GeodeticPoint gp = new GeodeticPoint(geodeticLatitude, longitude, 0);
223 // position in Cartesian coordinates, is converted to geocentric lat and
224 // lon in the Holmes and Featherstone class
225 final Vector3D position = ellipsoid.transform(gp);
226
227 // get normal gravity from ellipsoid, eq 15
228 final double normalGravity = ellipsoid
229 .getNormalGravity(geodeticLatitude);
230
231 // calculate disturbing potential, T, eq 30.
232 final double mu = this.harmonics.getMu(date);
233 final double T = this.harmonics.nonCentralPart(date, position, mu);
234 // calculate undulation, eq 30
235 return T / normalGravity;
236 }
237
238 @Override
239 public ReferenceEllipsoid getEllipsoid() {
240 return this.referenceEllipsoid;
241 }
242
243 /**
244 * This class implements equations 20-24 in the geoid cook book.(Losch and
245 * Seufer) It modifies C<sub>2n,0</sub> where n = 1,2,...,5.
246 *
247 * @see "DMA TR 8350.2. 1984."
248 */
249 private static final class SubtractEllipsoid implements
250 NormalizedSphericalHarmonicsProvider {
251 /**
252 * provider of the fully normalized coefficients, includes the reference
253 * ellipsoid.
254 */
255 private final NormalizedSphericalHarmonicsProvider provider;
256 /**
257 * the reference ellipsoid to subtract from {@link #provider}.
258 */
259 private final ReferenceEllipsoid ellipsoid;
260
261 /**
262 * @param provider potential used for GM<sub>g</sub> and a<sub>g</sub>,
263 * and of course the coefficients Cnm, and Snm.
264 * @param ellipsoid Used to calculate the fully normalized
265 * J<sub>2n</sub>
266 */
267 private SubtractEllipsoid(
268 final NormalizedSphericalHarmonicsProvider provider,
269 final ReferenceEllipsoid ellipsoid) {
270 super();
271 this.provider = provider;
272 this.ellipsoid = ellipsoid;
273 }
274
275 @Override
276 public int getMaxDegree() {
277 return this.provider.getMaxDegree();
278 }
279
280 @Override
281 public int getMaxOrder() {
282 return this.provider.getMaxOrder();
283 }
284
285 @Override
286 public double getMu() {
287 return this.provider.getMu();
288 }
289
290 @Override
291 public double getAe() {
292 return this.provider.getAe();
293 }
294
295 @Override
296 public AbsoluteDate getReferenceDate() {
297 return this.provider.getReferenceDate();
298 }
299
300 @Override
301 public NormalizedSphericalHarmonics onDate(final AbsoluteDate date) {
302 return new NormalizedSphericalHarmonics() {
303
304 /** the original harmonics */
305 private final NormalizedSphericalHarmonics delegate = provider.onDate(date);
306
307 @Override
308 public double getNormalizedCnm(final int n, final int m) {
309 return getCorrectedCnm(n, m, this.delegate.getNormalizedCnm(n, m));
310 }
311
312 @Override
313 public double getNormalizedSnm(final int n, final int m) {
314 return this.delegate.getNormalizedSnm(n, m);
315 }
316
317 @Override
318 public AbsoluteDate getDate() {
319 return date;
320 }
321 };
322 }
323
324 /**
325 * Get the corrected Cnm for different GM or a values.
326 *
327 * @param n degree
328 * @param m order
329 * @param uncorrectedCnm uncorrected Cnm coefficient
330 * @return the corrected Cnm coefficient.
331 */
332 private double getCorrectedCnm(final int n,
333 final int m,
334 final double uncorrectedCnm) {
335 double Cnm = uncorrectedCnm;
336 // n = 2,4,6,8, or 10 and m = 0
337 if (m == 0 && n <= 10 && n % 2 == 0 && n > 0) {
338 // correction factor for different GM and a, 1 if no difference
339 final double gmRatio = this.ellipsoid.getGM() / this.getMu();
340 final double aRatio = this.ellipsoid.getEquatorialRadius() /
341 this.getAe();
342 /*
343 * eq 20 in the geoid cook book[2], with eq 3-61 in chapter 3 of
344 * DMA TR 8350.2
345 */
346 // halfN = 1,2,3,4,5 for n = 2,4,6,8,10, respectively
347 final int halfN = n / 2;
348 Cnm = Cnm - gmRatio * FastMath.pow(aRatio, halfN) *
349 this.ellipsoid.getC2n0(halfN);
350 }
351 // return is a modified Cnm
352 return Cnm;
353 }
354
355 @Override
356 public TideSystem getTideSystem() {
357 return this.provider.getTideSystem();
358 }
359
360 }
361
362 /**
363 * {@inheritDoc}
364 *
365 * <p> The intersection point is computed using a line search along the
366 * specified line. This is accurate when the geoid is slowly varying.
367 */
368 @Override
369 public GeodeticPoint getIntersectionPoint(final Line lineInFrame,
370 final Vector3D closeInFrame,
371 final Frame frame,
372 final AbsoluteDate date) {
373 /*
374 * It is assumed that the geoid is slowly varying over it's entire
375 * surface. Therefore there will one local intersection.
376 */
377 // transform to body frame
378 final Frame bodyFrame = this.getBodyFrame();
379 final StaticTransform frameToBody =
380 frame.getStaticTransformTo(bodyFrame, date);
381 final Vector3D close = frameToBody.transformPosition(closeInFrame);
382 final Line lineInBodyFrame = frameToBody.transformLine(lineInFrame);
383
384 // set the line's direction so the solved for value is always positive
385 final Line line;
386 if (lineInBodyFrame.getAbscissa(close) < 0) {
387 line = lineInBodyFrame.revert();
388 } else {
389 line = lineInBodyFrame;
390 }
391
392 final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
393 // calculate end points
394 // distance from line to center of earth, squared
395 final double d2 = line.pointAt(0.0).getNormSq();
396 // the minimum abscissa, squared
397 final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
398 final double minAbscissa2 = n * n - d2;
399 // smaller end point of the interval = 0.0 or intersection with
400 // min_undulation sphere
401 final double lowPoint = FastMath.sqrt(FastMath.max(minAbscissa2, 0.0));
402 // the maximum abscissa, squared
403 final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
404 final double maxAbscissa2 = x * x - d2;
405 // larger end point of the interval
406 final double highPoint = FastMath.sqrt(maxAbscissa2);
407
408 // line search function
409 final UnivariateFunction heightFunction = x1 -> {
410 try {
411 final GeodeticPoint geodetic =
412 transform(line.pointAt(x1), bodyFrame, date);
413 return geodetic.getAltitude();
414 } catch (OrekitException e) {
415 // due to frame transform -> re-throw
416 throw new RuntimeException(e);
417 }
418 };
419
420 // compute answer
421 if (maxAbscissa2 < 0) {
422 // ray does not pierce bounding sphere -> no possible intersection
423 return null;
424 }
425 // solve line search problem to find the intersection
426 final UnivariateSolver solver = new BracketingNthOrderBrentSolver();
427 try {
428 final double abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint);
429 // return intersection point
430 return this.transform(line.pointAt(abscissa), bodyFrame, date);
431 } catch (MathRuntimeException e) {
432 // no intersection
433 return null;
434 }
435 }
436
437 @Override
438 public Vector3D projectToGround(final Vector3D point,
439 final AbsoluteDate date,
440 final Frame frame) {
441 final GeodeticPoint gp = this.transform(point, frame, date);
442 final GeodeticPoint gpZero =
443 new GeodeticPoint(gp.getLatitude(), gp.getLongitude(), 0);
444 final StaticTransform bodyToFrame =
445 this.getBodyFrame().getStaticTransformTo(frame, date);
446 return bodyToFrame.transformPosition(this.transform(gpZero));
447 }
448
449 /**
450 * {@inheritDoc}
451 *
452 * <p> The intersection point is computed using a line search along the
453 * specified line. This is accurate when the geoid is slowly varying.
454 */
455 @Override
456 public <T extends CalculusFieldElement<T>> FieldGeodeticPoint<T> getIntersectionPoint(final FieldLine<T> lineInFrame,
457 final FieldVector3D<T> closeInFrame,
458 final Frame frame,
459 final FieldAbsoluteDate<T> date) {
460
461 final Field<T> field = date.getField();
462 /*
463 * It is assumed that the geoid is slowly varying over it's entire
464 * surface. Therefore there will one local intersection.
465 */
466 // transform to body frame
467 final Frame bodyFrame = this.getBodyFrame();
468 final FieldStaticTransform<T> frameToBody = frame.getStaticTransformTo(bodyFrame, date);
469 final FieldVector3D<T> close = frameToBody.transformPosition(closeInFrame);
470 final FieldLine<T> lineInBodyFrame = frameToBody.transformLine(lineInFrame);
471
472 // set the line's direction so the solved for value is always positive
473 final FieldLine<T> line;
474 if (lineInBodyFrame.getAbscissa(close).getReal() < 0) {
475 line = lineInBodyFrame.revert();
476 } else {
477 line = lineInBodyFrame;
478 }
479
480 final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
481 // calculate end points
482 // distance from line to center of earth, squared
483 final T d2 = line.pointAt(0.0).getNormSq();
484 // the minimum abscissa, squared
485 final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
486 final T minAbscissa2 = d2.negate().add(n * n);
487 // smaller end point of the interval = 0.0 or intersection with
488 // min_undulation sphere
489 final T lowPoint = minAbscissa2.getReal() < 0 ? field.getZero() : minAbscissa2.sqrt();
490 // the maximum abscissa, squared
491 final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
492 final T maxAbscissa2 = d2.negate().add(x * x);
493 // larger end point of the interval
494 final T highPoint = maxAbscissa2.sqrt();
495
496 // line search function
497 final CalculusFieldUnivariateFunction<T> heightFunction = z -> {
498 try {
499 final FieldGeodeticPoint<T> geodetic =
500 transform(line.pointAt(z), bodyFrame, date);
501 return geodetic.getAltitude();
502 } catch (OrekitException e) {
503 // due to frame transform -> re-throw
504 throw new RuntimeException(e);
505 }
506 };
507
508 // compute answer
509 if (maxAbscissa2.getReal() < 0) {
510 // ray does not pierce bounding sphere -> no possible intersection
511 return null;
512 }
513 // solve line search problem to find the intersection
514 final FieldBracketingNthOrderBrentSolver<T> solver =
515 new FieldBracketingNthOrderBrentSolver<>(field.getZero().newInstance(1.0e-14),
516 field.getZero().newInstance(1.0e-6),
517 field.getZero().newInstance(1.0e-15),
518 5);
519 try {
520 final T abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint,
521 AllowedSolution.ANY_SIDE);
522 // return intersection point
523 return this.transform(line.pointAt(abscissa), bodyFrame, date);
524 } catch (MathRuntimeException e) {
525 // no intersection
526 return null;
527 }
528 }
529
530 @Override
531 public TimeStampedPVCoordinates projectToGround(
532 final TimeStampedPVCoordinates pv,
533 final Frame frame) {
534 throw new UnsupportedOperationException();
535 }
536
537 /**
538 * {@inheritDoc}
539 *
540 * @param date date of the conversion. Used for computing frame
541 * transformations and for time dependent geopotential.
542 * @return The surface relative point at the same location. Altitude is
543 * orthometric height, that is height above the {@link Geoid}. Latitude and
544 * longitude are both geodetic and defined with respect to the {@link
545 * #getEllipsoid() reference ellipsoid}.
546 * @see #transform(GeodeticPoint)
547 * @see <a href="http://en.wikipedia.org/wiki/Orthometric_height">Orthometric_height</a>
548 */
549 @Override
550 public GeodeticPoint transform(final Vector3D point, final Frame frame,
551 final AbsoluteDate date) {
552 // convert using reference ellipsoid, altitude referenced to ellipsoid
553 final GeodeticPoint ellipsoidal = this.getEllipsoid().transform(
554 point, frame, date);
555 // convert altitude to orthometric using the undulation.
556 final double undulation = this.getUndulation(ellipsoidal.getLatitude(),
557 ellipsoidal.getLongitude(), date);
558 // add undulation to the altitude
559 return new GeodeticPoint(
560 ellipsoidal.getLatitude(),
561 ellipsoidal.getLongitude(),
562 ellipsoidal.getAltitude() - undulation
563 );
564 }
565
566 /**
567 * {@inheritDoc}
568 *
569 * @param date date of the conversion. Used for computing frame
570 * transformations and for time dependent geopotential.
571 * @return The surface relative point at the same location. Altitude is
572 * orthometric height, that is height above the {@link Geoid}. Latitude and
573 * longitude are both geodetic and defined with respect to the {@link
574 * #getEllipsoid() reference ellipsoid}.
575 * @see #transform(GeodeticPoint)
576 * @see <a href="http://en.wikipedia.org/wiki/Orthometric_height">Orthometric_height</a>
577 */
578 @Override
579 public <T extends CalculusFieldElement<T>> FieldGeodeticPoint<T> transform(final FieldVector3D<T> point, final Frame frame,
580 final FieldAbsoluteDate<T> date) {
581 // convert using reference ellipsoid, altitude referenced to ellipsoid
582 final FieldGeodeticPoint<T> ellipsoidal = this.getEllipsoid().transform(
583 point, frame, date);
584 // convert altitude to orthometric using the undulation.
585 final double undulation = this.getUndulation(ellipsoidal.getLatitude().getReal(),
586 ellipsoidal.getLongitude().getReal(),
587 date.toAbsoluteDate());
588 // add undulation to the altitude
589 return new FieldGeodeticPoint<>(
590 ellipsoidal.getLatitude(),
591 ellipsoidal.getLongitude(),
592 ellipsoidal.getAltitude().subtract(undulation)
593 );
594 }
595
596 /**
597 * {@inheritDoc}
598 *
599 * @param point The surface relative point to transform. Altitude is
600 * orthometric height, that is height above the {@link Geoid}.
601 * Latitude and longitude are both geodetic and defined with
602 * respect to the {@link #getEllipsoid() reference ellipsoid}.
603 * @return point at the same location but as a Cartesian point in the {@link
604 * #getBodyFrame() body frame}.
605 * @see #transform(Vector3D, Frame, AbsoluteDate)
606 */
607 @Override
608 public Vector3D transform(final GeodeticPoint point) {
609 try {
610 // convert orthometric height to height above ellipsoid using undulation
611 // TODO pass in date to allow user to specify
612 final double undulation = this.getUndulation(
613 point.getLatitude(),
614 point.getLongitude(),
615 this.defaultDate
616 );
617 final GeodeticPoint ellipsoidal = new GeodeticPoint(
618 point.getLatitude(),
619 point.getLongitude(),
620 point.getAltitude() + undulation
621 );
622 // transform using reference ellipsoid
623 return this.getEllipsoid().transform(ellipsoidal);
624 } catch (OrekitException e) {
625 //this method, as defined in BodyShape, is not permitted to throw
626 //an OrekitException, so wrap in an exception we can throw.
627 throw new RuntimeException(e);
628 }
629 }
630
631 /**
632 * {@inheritDoc}
633 *
634 * @param point The surface relative point to transform. Altitude is
635 * orthometric height, that is height above the {@link Geoid}.
636 * Latitude and longitude are both geodetic and defined with
637 * respect to the {@link #getEllipsoid() reference ellipsoid}.
638 * @param <T> type of the field elements
639 * @return point at the same location but as a Cartesian point in the {@link
640 * #getBodyFrame() body frame}.
641 * @see #transform(Vector3D, Frame, AbsoluteDate)
642 * @since 9.0
643 */
644 @Override
645 public <T extends CalculusFieldElement<T>> FieldVector3D<T> transform(final FieldGeodeticPoint<T> point) {
646 try {
647 // convert orthometric height to height above ellipsoid using undulation
648 // TODO pass in date to allow user to specify
649 final double undulation = this.getUndulation(
650 point.getLatitude().getReal(),
651 point.getLongitude().getReal(),
652 this.defaultDate
653 );
654 final FieldGeodeticPoint<T> ellipsoidal = new FieldGeodeticPoint<>(
655 point.getLatitude(),
656 point.getLongitude(),
657 point.getAltitude().add(undulation)
658 );
659 // transform using reference ellipsoid
660 return this.getEllipsoid().transform(ellipsoidal);
661 } catch (OrekitException e) {
662 //this method, as defined in BodyShape, is not permitted to throw
663 //an OrekitException, so wrap in an exception we can throw.
664 throw new RuntimeException(e);
665 }
666 }
667
668 }