Geoid.java

  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. import org.hipparchus.Field;
  19. import org.hipparchus.CalculusFieldElement;
  20. import org.hipparchus.analysis.CalculusFieldUnivariateFunction;
  21. import org.hipparchus.analysis.UnivariateFunction;
  22. import org.hipparchus.analysis.solvers.AllowedSolution;
  23. import org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver;
  24. import org.hipparchus.analysis.solvers.FieldBracketingNthOrderBrentSolver;
  25. import org.hipparchus.analysis.solvers.UnivariateSolver;
  26. import org.hipparchus.exception.MathRuntimeException;
  27. import org.hipparchus.geometry.euclidean.threed.FieldLine;
  28. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  29. import org.hipparchus.geometry.euclidean.threed.Line;
  30. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  31. import org.hipparchus.util.FastMath;
  32. import org.orekit.bodies.FieldGeodeticPoint;
  33. import org.orekit.bodies.GeodeticPoint;
  34. import org.orekit.errors.OrekitException;
  35. import org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel;
  36. import org.orekit.forces.gravity.potential.GravityFields;
  37. import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider;
  38. import org.orekit.forces.gravity.potential.TideSystem;
  39. import org.orekit.frames.FieldTransform;
  40. import org.orekit.frames.Frame;
  41. import org.orekit.frames.StaticTransform;
  42. import org.orekit.time.AbsoluteDate;
  43. import org.orekit.time.FieldAbsoluteDate;
  44. import org.orekit.utils.TimeStampedPVCoordinates;

  45. /**
  46.  * A geoid is a level surface of the gravity potential of a body. The gravity
  47.  * potential, W, is split so W = U + T, where U is the normal potential (defined
  48.  * by the ellipsoid) and T is the anomalous potential.[3](eq. 2-137)
  49.  *
  50.  * <p> The {@link #getIntersectionPoint(Line, Vector3D, Frame, AbsoluteDate)}
  51.  * method is tailored specifically for Earth's geoid. All of the other methods
  52.  * in this class are general and will work for an arbitrary body.
  53.  *
  54.  * <p> There are several components that are needed to define a geoid[1]:
  55.  *
  56.  * <ul> <li>Geopotential field. These are the coefficients of the spherical
  57.  * harmonics: S<sub>n,m</sub> and C<sub>n,m</sub></li>
  58.  *
  59.  * <li>Reference Ellipsoid. The ellipsoid is used to define the undulation of
  60.  * the geoid (distance between ellipsoid and geoid) and U<sub>0</sub> the value
  61.  * of the normal gravity potential at the surface of the ellipsoid.</li>
  62.  *
  63.  * <li>W<sub>0</sub>, the potential at the geoid. The value of the potential on
  64.  * the level surface. This is taken to be U<sub>0</sub>, the normal gravity
  65.  * potential at the surface of the {@link ReferenceEllipsoid}.</li>
  66.  *
  67.  * <li>Permanent Tide System. This implementation assumes that the geopotential
  68.  * field and the reference ellipsoid use the same permanent tide system. If the
  69.  * assumption is false it will produce errors of about 0.5 m. Conversion between
  70.  * tide systems is a possible improvement.[1,2]</li>
  71.  *
  72.  * <li>Topographic Masses. That is mass outside of the geoid, e.g. mountains.
  73.  * This implementation ignores topographic masses, which causes up to 3m error
  74.  * in the Himalayas, and ~ 1.5m error in the Rockies. This could be improved
  75.  * through the use of DTED and calculating height anomalies or using the
  76.  * correction coefficients.[1]</li> </ul>
  77.  *
  78.  * <p> This implementation also assumes that the normal to the reference
  79.  * ellipsoid is the same as the normal to the geoid. This assumption enables the
  80.  * equation: (height above geoid) = (height above ellipsoid) - (undulation),
  81.  * which is used in {@link #transform(GeodeticPoint)} and {@link
  82.  * #transform(Vector3D, Frame, AbsoluteDate)}.
  83.  *
  84.  * <p> In testing, the error in the undulations calculated by this class were
  85.  * off by less than 3 meters, which matches the assumptions outlined above.
  86.  *
  87.  * <p> References:
  88.  *
  89.  * <ol> <li>Dru A. Smith. There is no such thing as "The" EGM96 geoid: Subtle
  90.  * points on the use of a global geopotential model. IGeS Bulletin No. 8:17-28,
  91.  * 1998. <a href= "http://www.ngs.noaa.gov/PUBS_LIB/EGM96_GEOID_PAPER/egm96_geoid_paper.html"
  92.  * >http://www.ngs.noaa.gov/PUBS_LIB/EGM96_GEOID_PAPER/egm96_geoid_paper.html</a></li>
  93.  *
  94.  * <li> Martin Losch, Verena Seufer. How to Compute Geoid Undulations (Geoid
  95.  * Height Relative to a Given Reference Ellipsoid) from Spherical Harmonic
  96.  * Coefficients for Satellite Altimetry Applications. , 2003. <a
  97.  * href="http://mitgcm.org/~mlosch/geoidcookbook.pdf">mitgcm.org/~mlosch/geoidcookbook.pdf</a>
  98.  * </li>
  99.  *
  100.  * <li>Weikko A. Heiskanen, Helmut Moritz. Physical Geodesy. W. H. Freeman and
  101.  * Company, 1967. (especially sections 2.13 and equation 2-144 Bruns
  102.  * Formula)</li>
  103.  *
  104.  * <li>S. A. Holmes, W. E. Featherstone. A unified approach to the Clenshaw
  105.  * summation and the recursive computation of very high degree and order
  106.  * normalised associated Legendre functions. Journal of Geodesy, 76(5):279,
  107.  * 2002.</li>
  108.  *
  109.  * <li>DMA TR 8350.2. 1984.</li>
  110.  *
  111.  * <li>Department of Defense World Geodetic System 1984. 2000. NIMA TR 8350.2
  112.  * Third Edition, Amendment 1.</li> </ol>
  113.  *
  114.  * @author Evan Ward
  115.  */
  116. public class Geoid implements EarthShape {

  117.     /**
  118.      * uid is date of last modification.
  119.      */
  120.     private static final long serialVersionUID = 20150312L;

  121.     /**
  122.      * A number larger than the largest undulation. Wikipedia says the geoid
  123.      * height is in [-106, 85]. I chose 100 to be safe.
  124.      */
  125.     private static final double MAX_UNDULATION = 100;
  126.     /**
  127.      * A number smaller than the smallest undulation. Wikipedia says the geoid
  128.      * height is in [-106, 85]. I chose -150 to be safe.
  129.      */
  130.     private static final double MIN_UNDULATION = -150;
  131.     /**
  132.      * the maximum number of evaluations for the line search in {@link
  133.      * #getIntersectionPoint(Line, Vector3D, Frame, AbsoluteDate)}.
  134.      */
  135.     private static final int MAX_EVALUATIONS = 100;

  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.      * Creates a geoid from the given geopotential, reference ellipsoid and the
  152.      * assumptions in the comment for {@link Geoid}.
  153.      *
  154.      * @param geopotential       the gravity potential. Only the anomalous
  155.      *                           potential will be used. It is assumed that the
  156.      *                           {@code geopotential} and the {@code
  157.      *                           referenceEllipsoid} are defined in the same
  158.      *                           frame. Usually a {@link GravityFields#getConstantNormalizedProvider(int,
  159.      *                           int) constant geopotential} is used to define a
  160.      *                           time-invariant Geoid.
  161.      * @param referenceEllipsoid the normal gravity potential.
  162.      * @throws NullPointerException if {@code geopotential == null ||
  163.      *                              referenceEllipsoid == null}
  164.      */
  165.     public Geoid(final NormalizedSphericalHarmonicsProvider geopotential,
  166.                  final ReferenceEllipsoid referenceEllipsoid) {
  167.         // parameter check
  168.         if (geopotential == null || referenceEllipsoid == null) {
  169.             throw new NullPointerException();
  170.         }

  171.         // subtract the ellipsoid from the geopotential
  172.         final SubtractEllipsoid potential = new SubtractEllipsoid(geopotential,
  173.                 referenceEllipsoid);

  174.         // set instance parameters
  175.         this.referenceEllipsoid = referenceEllipsoid;
  176.         this.harmonics = new HolmesFeatherstoneAttractionModel(
  177.                 referenceEllipsoid.getBodyFrame(), potential);
  178.         this.defaultDate = AbsoluteDate.ARBITRARY_EPOCH;
  179.     }

  180.     @Override
  181.     public Frame getBodyFrame() {
  182.         // same as for reference ellipsoid.
  183.         return this.getEllipsoid().getBodyFrame();
  184.     }

  185.     /**
  186.      * Gets the Undulation of the Geoid, N at the given position. N is the
  187.      * distance between the {@link #getEllipsoid() reference ellipsoid} and the
  188.      * geoid. The latitude and longitude parameters are both defined with
  189.      * respect to the reference ellipsoid. For EGM96 and the WGS84 ellipsoid the
  190.      * undulation is between -107m and +86m.
  191.      *
  192.      * <p> NOTE: Restrictions are not put on the range of the arguments {@code
  193.      * geodeticLatitude} and {@code longitude}.
  194.      *
  195.      * @param geodeticLatitude geodetic latitude (angle between the local normal
  196.      *                         and the equatorial plane on the reference
  197.      *                         ellipsoid), in radians.
  198.      * @param longitude        on the reference ellipsoid, in radians.
  199.      * @param date             of evaluation. Used for time varying geopotential
  200.      *                         fields.
  201.      * @return the undulation in m, positive means the geoid is higher than the
  202.      * ellipsoid.
  203.      * @see Geoid
  204.      * @see <a href="http://en.wikipedia.org/wiki/Geoid">Geoid on Wikipedia</a>
  205.      */
  206.     public double getUndulation(final double geodeticLatitude,
  207.                                 final double longitude,
  208.                                 final AbsoluteDate date) {
  209.         /*
  210.          * equations references are to the algorithm printed in the geoid
  211.          * cookbook[2]. See comment for Geoid.
  212.          */
  213.         // reference ellipsoid
  214.         final ReferenceEllipsoid ellipsoid = this.getEllipsoid();

  215.         // position in geodetic coordinates
  216.         final GeodeticPoint gp = new GeodeticPoint(geodeticLatitude, longitude, 0);
  217.         // position in Cartesian coordinates, is converted to geocentric lat and
  218.         // lon in the Holmes and Featherstone class
  219.         final Vector3D position = ellipsoid.transform(gp);

  220.         // get normal gravity from ellipsoid, eq 15
  221.         final double normalGravity = ellipsoid
  222.                 .getNormalGravity(geodeticLatitude);

  223.         // calculate disturbing potential, T, eq 30.
  224.         final double mu = this.harmonics.getMu();
  225.         final double T  = this.harmonics.nonCentralPart(date, position, mu);
  226.         // calculate undulation, eq 30
  227.         return T / normalGravity;
  228.     }

  229.     @Override
  230.     public ReferenceEllipsoid getEllipsoid() {
  231.         return this.referenceEllipsoid;
  232.     }

  233.     /**
  234.      * This class implements equations 20-24 in the geoid cook book.(Losch and
  235.      * Seufer) It modifies C<sub>2n,0</sub> where n = 1,2,...,5.
  236.      *
  237.      * @see "DMA TR 8350.2. 1984."
  238.      */
  239.     private static final class SubtractEllipsoid implements
  240.             NormalizedSphericalHarmonicsProvider {
  241.         /**
  242.          * provider of the fully normalized coefficients, includes the reference
  243.          * ellipsoid.
  244.          */
  245.         private final NormalizedSphericalHarmonicsProvider provider;
  246.         /**
  247.          * the reference ellipsoid to subtract from {@link #provider}.
  248.          */
  249.         private final ReferenceEllipsoid ellipsoid;

  250.         /**
  251.          * @param provider  potential used for GM<sub>g</sub> and a<sub>g</sub>,
  252.          *                  and of course the coefficients Cnm, and Snm.
  253.          * @param ellipsoid Used to calculate the fully normalized
  254.          *                  J<sub>2n</sub>
  255.          */
  256.         private SubtractEllipsoid(
  257.                 final NormalizedSphericalHarmonicsProvider provider,
  258.                 final ReferenceEllipsoid ellipsoid) {
  259.             super();
  260.             this.provider = provider;
  261.             this.ellipsoid = ellipsoid;
  262.         }

  263.         @Override
  264.         public int getMaxDegree() {
  265.             return this.provider.getMaxDegree();
  266.         }

  267.         @Override
  268.         public int getMaxOrder() {
  269.             return this.provider.getMaxOrder();
  270.         }

  271.         @Override
  272.         public double getMu() {
  273.             return this.provider.getMu();
  274.         }

  275.         @Override
  276.         public double getAe() {
  277.             return this.provider.getAe();
  278.         }

  279.         @Override
  280.         public AbsoluteDate getReferenceDate() {
  281.             return this.provider.getReferenceDate();
  282.         }

  283.         @Deprecated
  284.         @Override
  285.         public double getOffset(final AbsoluteDate date) {
  286.             return this.provider.getOffset(date);
  287.         }

  288.         @Override
  289.         public NormalizedSphericalHarmonics onDate(final AbsoluteDate date) {
  290.             return new NormalizedSphericalHarmonics() {

  291.                 /** the original harmonics */
  292.                 private final NormalizedSphericalHarmonics delegate = provider.onDate(date);

  293.                 @Override
  294.                 public double getNormalizedCnm(final int n, final int m) {
  295.                     return getCorrectedCnm(n, m, this.delegate.getNormalizedCnm(n, m));
  296.                 }

  297.                 @Override
  298.                 public double getNormalizedSnm(final int n, final int m) {
  299.                     return this.delegate.getNormalizedSnm(n, m);
  300.                 }

  301.                 @Override
  302.                 public AbsoluteDate getDate() {
  303.                     return date;
  304.                 }
  305.             };
  306.         }

  307.         /**
  308.          * Get the corrected Cnm for different GM or a values.
  309.          *
  310.          * @param n              degree
  311.          * @param m              order
  312.          * @param uncorrectedCnm uncorrected Cnm coefficient
  313.          * @return the corrected Cnm coefficient.
  314.          */
  315.         private double getCorrectedCnm(final int n,
  316.                                        final int m,
  317.                                        final double uncorrectedCnm) {
  318.             double Cnm = uncorrectedCnm;
  319.             // n = 2,4,6,8, or 10 and m = 0
  320.             if (m == 0 && n <= 10 && n % 2 == 0 && n > 0) {
  321.                 // correction factor for different GM and a, 1 if no difference
  322.                 final double gmRatio = this.ellipsoid.getGM() / this.getMu();
  323.                 final double aRatio = this.ellipsoid.getEquatorialRadius() /
  324.                         this.getAe();
  325.                 /*
  326.                  * eq 20 in the geoid cook book[2], with eq 3-61 in chapter 3 of
  327.                  * DMA TR 8350.2
  328.                  */
  329.                 // halfN = 1,2,3,4,5 for n = 2,4,6,8,10, respectively
  330.                 final int halfN = n / 2;
  331.                 Cnm = Cnm - gmRatio * FastMath.pow(aRatio, halfN) *
  332.                         this.ellipsoid.getC2n0(halfN);
  333.             }
  334.             // return is a modified Cnm
  335.             return Cnm;
  336.         }

  337.         @Override
  338.         public TideSystem getTideSystem() {
  339.             return this.provider.getTideSystem();
  340.         }

  341.     }

  342.     /**
  343.      * {@inheritDoc}
  344.      *
  345.      * <p> The intersection point is computed using a line search along the
  346.      * specified line. This is accurate when the geoid is slowly varying.
  347.      */
  348.     @Override
  349.     public GeodeticPoint getIntersectionPoint(final Line lineInFrame,
  350.                                               final Vector3D closeInFrame,
  351.                                               final Frame frame,
  352.                                               final AbsoluteDate date) {
  353.         /*
  354.          * It is assumed that the geoid is slowly varying over it's entire
  355.          * surface. Therefore there will one local intersection.
  356.          */
  357.         // transform to body frame
  358.         final Frame bodyFrame = this.getBodyFrame();
  359.         final StaticTransform frameToBody =
  360.                 frame.getStaticTransformTo(bodyFrame, date);
  361.         final Vector3D close = frameToBody.transformPosition(closeInFrame);
  362.         final Line lineInBodyFrame = frameToBody.transformLine(lineInFrame);

  363.         // set the line's direction so the solved for value is always positive
  364.         final Line line;
  365.         if (lineInBodyFrame.getAbscissa(close) < 0) {
  366.             line = lineInBodyFrame.revert();
  367.         } else {
  368.             line = lineInBodyFrame;
  369.         }

  370.         final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
  371.         // calculate end points
  372.         // distance from line to center of earth, squared
  373.         final double d2 = line.pointAt(0.0).getNormSq();
  374.         // the minimum abscissa, squared
  375.         final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
  376.         final double minAbscissa2 = n * n - d2;
  377.         // smaller end point of the interval = 0.0 or intersection with
  378.         // min_undulation sphere
  379.         final double lowPoint = FastMath.sqrt(FastMath.max(minAbscissa2, 0.0));
  380.         // the maximum abscissa, squared
  381.         final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
  382.         final double maxAbscissa2 = x * x - d2;
  383.         // larger end point of the interval
  384.         final double highPoint = FastMath.sqrt(maxAbscissa2);

  385.         // line search function
  386.         final UnivariateFunction heightFunction = new UnivariateFunction() {
  387.             @Override
  388.             public double value(final double x) {
  389.                 try {
  390.                     final GeodeticPoint geodetic =
  391.                             transform(line.pointAt(x), bodyFrame, date);
  392.                     return geodetic.getAltitude();
  393.                 } catch (OrekitException e) {
  394.                     // due to frame transform -> re-throw
  395.                     throw new RuntimeException(e);
  396.                 }
  397.             }
  398.         };

  399.         // compute answer
  400.         if (maxAbscissa2 < 0) {
  401.             // ray does not pierce bounding sphere -> no possible intersection
  402.             return null;
  403.         }
  404.         // solve line search problem to find the intersection
  405.         final UnivariateSolver solver = new BracketingNthOrderBrentSolver();
  406.         try {
  407.             final double abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint);
  408.             // return intersection point
  409.             return this.transform(line.pointAt(abscissa), bodyFrame, date);
  410.         } catch (MathRuntimeException e) {
  411.             // no intersection
  412.             return null;
  413.         }
  414.     }

  415.     @Override
  416.     public Vector3D projectToGround(final Vector3D point,
  417.                                     final AbsoluteDate date,
  418.                                     final Frame frame) {
  419.         final GeodeticPoint gp = this.transform(point, frame, date);
  420.         final GeodeticPoint gpZero =
  421.                 new GeodeticPoint(gp.getLatitude(), gp.getLongitude(), 0);
  422.         final StaticTransform bodyToFrame =
  423.                 this.getBodyFrame().getStaticTransformTo(frame, date);
  424.         return bodyToFrame.transformPosition(this.transform(gpZero));
  425.     }

  426.     /**
  427.      * {@inheritDoc}
  428.      *
  429.      * <p> The intersection point is computed using a line search along the
  430.      * specified line. This is accurate when the geoid is slowly varying.
  431.      */
  432.     @Override
  433.     public <T extends CalculusFieldElement<T>> FieldGeodeticPoint<T> getIntersectionPoint(final FieldLine<T> lineInFrame,
  434.                                                                                       final FieldVector3D<T> closeInFrame,
  435.                                                                                       final Frame frame,
  436.                                                                                       final FieldAbsoluteDate<T> date) {

  437.         final Field<T> field = date.getField();
  438.         /*
  439.          * It is assumed that the geoid is slowly varying over it's entire
  440.          * surface. Therefore there will one local intersection.
  441.          */
  442.         // transform to body frame
  443.         final Frame bodyFrame = this.getBodyFrame();
  444.         final FieldTransform<T> frameToBody = frame.getTransformTo(bodyFrame, date);
  445.         final FieldVector3D<T> close = frameToBody.transformPosition(closeInFrame);
  446.         final FieldLine<T> lineInBodyFrame = frameToBody.transformLine(lineInFrame);

  447.         // set the line's direction so the solved for value is always positive
  448.         final FieldLine<T> line;
  449.         if (lineInBodyFrame.getAbscissa(close).getReal() < 0) {
  450.             line = lineInBodyFrame.revert();
  451.         } else {
  452.             line = lineInBodyFrame;
  453.         }

  454.         final ReferenceEllipsoid ellipsoid = this.getEllipsoid();
  455.         // calculate end points
  456.         // distance from line to center of earth, squared
  457.         final T d2 = line.pointAt(0.0).getNormSq();
  458.         // the minimum abscissa, squared
  459.         final double n = ellipsoid.getPolarRadius() + MIN_UNDULATION;
  460.         final T minAbscissa2 = d2.negate().add(n * n);
  461.         // smaller end point of the interval = 0.0 or intersection with
  462.         // min_undulation sphere
  463.         final T lowPoint = minAbscissa2.getReal() < 0 ? field.getZero() : minAbscissa2.sqrt();
  464.         // the maximum abscissa, squared
  465.         final double x = ellipsoid.getEquatorialRadius() + MAX_UNDULATION;
  466.         final T maxAbscissa2 = d2.negate().add(x * x);
  467.         // larger end point of the interval
  468.         final T highPoint = maxAbscissa2.sqrt();

  469.         // line search function
  470.         final CalculusFieldUnivariateFunction<T> heightFunction = z -> {
  471.             try {
  472.                 final FieldGeodeticPoint<T> geodetic =
  473.                         transform(line.pointAt(z), bodyFrame, date);
  474.                 return geodetic.getAltitude();
  475.             } catch (OrekitException e) {
  476.                 // due to frame transform -> re-throw
  477.                 throw new RuntimeException(e);
  478.             }
  479.         };

  480.         // compute answer
  481.         if (maxAbscissa2.getReal() < 0) {
  482.             // ray does not pierce bounding sphere -> no possible intersection
  483.             return null;
  484.         }
  485.         // solve line search problem to find the intersection
  486.         final FieldBracketingNthOrderBrentSolver<T> solver =
  487.                         new FieldBracketingNthOrderBrentSolver<>(field.getZero().add(1.0e-14),
  488.                                                                  field.getZero().add(1.0e-6),
  489.                                                                  field.getZero().add(1.0e-15),
  490.                                                                  5);
  491.         try {
  492.             final T abscissa = solver.solve(MAX_EVALUATIONS, heightFunction, lowPoint, highPoint,
  493.                                             AllowedSolution.ANY_SIDE);
  494.             // return intersection point
  495.             return this.transform(line.pointAt(abscissa), bodyFrame, date);
  496.         } catch (MathRuntimeException e) {
  497.             // no intersection
  498.             return null;
  499.         }
  500.     }

  501.     @Override
  502.     public TimeStampedPVCoordinates projectToGround(
  503.             final TimeStampedPVCoordinates pv,
  504.             final Frame frame) {
  505.         throw new UnsupportedOperationException();
  506.     }

  507.     /**
  508.      * {@inheritDoc}
  509.      *
  510.      * @param date date of the conversion. Used for computing frame
  511.      *             transformations and for time dependent geopotential.
  512.      * @return The surface relative point at the same location. Altitude is
  513.      * orthometric height, that is height above the {@link Geoid}. Latitude and
  514.      * longitude are both geodetic and defined with respect to the {@link
  515.      * #getEllipsoid() reference ellipsoid}.
  516.      * @see #transform(GeodeticPoint)
  517.      * @see <a href="http://en.wikipedia.org/wiki/Orthometric_height">Orthometric_height</a>
  518.      */
  519.     @Override
  520.     public GeodeticPoint transform(final Vector3D point, final Frame frame,
  521.                                    final AbsoluteDate date) {
  522.         // convert using reference ellipsoid, altitude referenced to ellipsoid
  523.         final GeodeticPoint ellipsoidal = this.getEllipsoid().transform(
  524.                 point, frame, date);
  525.         // convert altitude to orthometric using the undulation.
  526.         final double undulation = this.getUndulation(ellipsoidal.getLatitude(),
  527.                 ellipsoidal.getLongitude(), date);
  528.         // add undulation to the altitude
  529.         return new GeodeticPoint(
  530.                 ellipsoidal.getLatitude(),
  531.                 ellipsoidal.getLongitude(),
  532.                 ellipsoidal.getAltitude() - undulation
  533.         );
  534.     }

  535.     /**
  536.      * {@inheritDoc}
  537.      *
  538.      * @param date date of the conversion. Used for computing frame
  539.      *             transformations and for time dependent geopotential.
  540.      * @return The surface relative point at the same location. Altitude is
  541.      * orthometric height, that is height above the {@link Geoid}. Latitude and
  542.      * longitude are both geodetic and defined with respect to the {@link
  543.      * #getEllipsoid() reference ellipsoid}.
  544.      * @see #transform(GeodeticPoint)
  545.      * @see <a href="http://en.wikipedia.org/wiki/Orthometric_height">Orthometric_height</a>
  546.      */
  547.     @Override
  548.     public <T extends CalculusFieldElement<T>> FieldGeodeticPoint<T> transform(final FieldVector3D<T> point, final Frame frame,
  549.                                                                            final FieldAbsoluteDate<T> date) {
  550.         // convert using reference ellipsoid, altitude referenced to ellipsoid
  551.         final FieldGeodeticPoint<T> ellipsoidal = this.getEllipsoid().transform(
  552.                 point, frame, date);
  553.         // convert altitude to orthometric using the undulation.
  554.         final double undulation = this.getUndulation(ellipsoidal.getLatitude().getReal(),
  555.                                                      ellipsoidal.getLongitude().getReal(),
  556.                                                      date.toAbsoluteDate());
  557.         // add undulation to the altitude
  558.         return new FieldGeodeticPoint<>(
  559.                 ellipsoidal.getLatitude(),
  560.                 ellipsoidal.getLongitude(),
  561.                 ellipsoidal.getAltitude().subtract(undulation)
  562.         );
  563.     }

  564.     /**
  565.      * {@inheritDoc}
  566.      *
  567.      * @param point The surface relative point to transform. Altitude is
  568.      *              orthometric height, that is height above the {@link Geoid}.
  569.      *              Latitude and longitude are both geodetic and defined with
  570.      *              respect to the {@link #getEllipsoid() reference ellipsoid}.
  571.      * @return point at the same location but as a Cartesian point in the {@link
  572.      * #getBodyFrame() body frame}.
  573.      * @see #transform(Vector3D, Frame, AbsoluteDate)
  574.      */
  575.     @Override
  576.     public Vector3D transform(final GeodeticPoint point) {
  577.         try {
  578.             // convert orthometric height to height above ellipsoid using undulation
  579.             // TODO pass in date to allow user to specify
  580.             final double undulation = this.getUndulation(
  581.                     point.getLatitude(),
  582.                     point.getLongitude(),
  583.                     this.defaultDate
  584.             );
  585.             final GeodeticPoint ellipsoidal = new GeodeticPoint(
  586.                     point.getLatitude(),
  587.                     point.getLongitude(),
  588.                     point.getAltitude() + undulation
  589.             );
  590.             // transform using reference ellipsoid
  591.             return this.getEllipsoid().transform(ellipsoidal);
  592.         } catch (OrekitException e) {
  593.             //this method, as defined in BodyShape, is not permitted to throw
  594.             //an OrekitException, so wrap in an exception we can throw.
  595.             throw new RuntimeException(e);
  596.         }
  597.     }

  598.     /**
  599.      * {@inheritDoc}
  600.      *
  601.      * @param point The surface relative point to transform. Altitude is
  602.      *              orthometric height, that is height above the {@link Geoid}.
  603.      *              Latitude and longitude are both geodetic and defined with
  604.      *              respect to the {@link #getEllipsoid() reference ellipsoid}.
  605.      * @param <T> type of the field elements
  606.      * @return point at the same location but as a Cartesian point in the {@link
  607.      * #getBodyFrame() body frame}.
  608.      * @see #transform(Vector3D, Frame, AbsoluteDate)
  609.      * @since 9.0
  610.      */
  611.     @Override
  612.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> transform(final FieldGeodeticPoint<T> point) {
  613.         try {
  614.             // convert orthometric height to height above ellipsoid using undulation
  615.             // TODO pass in date to allow user to specify
  616.             final double undulation = this.getUndulation(
  617.                     point.getLatitude().getReal(),
  618.                     point.getLongitude().getReal(),
  619.                     this.defaultDate
  620.             );
  621.             final FieldGeodeticPoint<T> ellipsoidal = new FieldGeodeticPoint<>(
  622.                     point.getLatitude(),
  623.                     point.getLongitude(),
  624.                     point.getAltitude().add(undulation)
  625.             );
  626.             // transform using reference ellipsoid
  627.             return this.getEllipsoid().transform(ellipsoidal);
  628.         } catch (OrekitException e) {
  629.             //this method, as defined in BodyShape, is not permitted to throw
  630.             //an OrekitException, so wrap in an exception we can throw.
  631.             throw new RuntimeException(e);
  632.         }
  633.     }

  634. }