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.CalculusFieldElement;
  19. import org.hipparchus.Field;
  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.FieldStaticTransform;
  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, AbsoluteDate) 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(date);
  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.         @Override
  284.         public NormalizedSphericalHarmonics onDate(final AbsoluteDate date) {
  285.             return new NormalizedSphericalHarmonics() {

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

  288.                 @Override
  289.                 public double getNormalizedCnm(final int n, final int m) {
  290.                     return getCorrectedCnm(n, m, this.delegate.getNormalizedCnm(n, m));
  291.                 }

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

  296.                 @Override
  297.                 public AbsoluteDate getDate() {
  298.                     return date;
  299.                 }
  300.             };
  301.         }

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

  332.         @Override
  333.         public TideSystem getTideSystem() {
  334.             return this.provider.getTideSystem();
  335.         }

  336.     }

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

  358.         // set the line's direction so the solved for value is always positive
  359.         final Line line;
  360.         if (lineInBodyFrame.getAbscissa(close) < 0) {
  361.             line = lineInBodyFrame.revert();
  362.         } else {
  363.             line = lineInBodyFrame;
  364.         }

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

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

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

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

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

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

  442.         // set the line's direction so the solved for value is always positive
  443.         final FieldLine<T> line;
  444.         if (lineInBodyFrame.getAbscissa(close).getReal() < 0) {
  445.             line = lineInBodyFrame.revert();
  446.         } else {
  447.             line = lineInBodyFrame;
  448.         }

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

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

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

  496.     @Override
  497.     public TimeStampedPVCoordinates projectToGround(
  498.             final TimeStampedPVCoordinates pv,
  499.             final Frame frame) {
  500.         throw new UnsupportedOperationException();
  501.     }

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

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

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

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

  629. }