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

  132.     /**
  133.      * the default date to use when evaluating the {@link #harmonics}. Used when
  134.      * no other dates are available. Should be removed in a future release.
  135.      */
  136.     private final AbsoluteDate defaultDate;
  137.     /**
  138.      * the reference ellipsoid.
  139.      */
  140.     private final ReferenceEllipsoid referenceEllipsoid;
  141.     /**
  142.      * the geo-potential combined with an algorithm for evaluating the spherical
  143.      * harmonics. The Holmes and Featherstone method is very robust.
  144.      */
  145.     private final transient HolmesFeatherstoneAttractionModel harmonics;

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

  167.         // subtract the ellipsoid from the geopotential
  168.         final SubtractEllipsoid potential = new SubtractEllipsoid(geopotential,
  169.                 referenceEllipsoid);

  170.         // set instance parameters
  171.         this.referenceEllipsoid = referenceEllipsoid;
  172.         this.harmonics = new HolmesFeatherstoneAttractionModel(
  173.                 referenceEllipsoid.getBodyFrame(), potential);
  174.         this.defaultDate = AbsoluteDate.ARBITRARY_EPOCH;
  175.     }

  176.     @Override
  177.     public Frame getBodyFrame() {
  178.         // same as for reference ellipsoid.
  179.         return this.getEllipsoid().getBodyFrame();
  180.     }

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

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

  216.         // get normal gravity from ellipsoid, eq 15
  217.         final double normalGravity = ellipsoid
  218.                 .getNormalGravity(geodeticLatitude);

  219.         // calculate disturbing potential, T, eq 30.
  220.         final double mu = this.harmonics.getMu(date);
  221.         final double T  = this.harmonics.nonCentralPart(date, position, mu);
  222.         // calculate undulation, eq 30
  223.         return T / normalGravity;
  224.     }

  225.     @Override
  226.     public ReferenceEllipsoid getEllipsoid() {
  227.         return this.referenceEllipsoid;
  228.     }

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

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

  259.         @Override
  260.         public int getMaxDegree() {
  261.             return this.provider.getMaxDegree();
  262.         }

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

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

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

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

  279.         @Override
  280.         public NormalizedSphericalHarmonics onDate(final AbsoluteDate date) {
  281.             return new NormalizedSphericalHarmonics() {

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

  284.                 @Override
  285.                 public double getNormalizedCnm(final int n, final int m) {
  286.                     return getCorrectedCnm(n, m, this.delegate.getNormalizedCnm(n, m));
  287.                 }

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

  292.                 @Override
  293.                 public AbsoluteDate getDate() {
  294.                     return date;
  295.                 }
  296.             };
  297.         }

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

  328.         @Override
  329.         public TideSystem getTideSystem() {
  330.             return this.provider.getTideSystem();
  331.         }

  332.     }

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

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

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

  376.         // line search function
  377.         final UnivariateFunction heightFunction = x1 -> {
  378.             try {
  379.                 final GeodeticPoint geodetic =
  380.                         transform(line.pointAt(x1), bodyFrame, date);
  381.                 return geodetic.getAltitude();
  382.             } catch (OrekitException e) {
  383.                 // due to frame transform -> re-throw
  384.                 throw new RuntimeException(e);
  385.             }
  386.         };

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

  403.     @Override
  404.     public Vector3D projectToGround(final Vector3D point,
  405.                                     final AbsoluteDate date,
  406.                                     final Frame frame) {
  407.         final GeodeticPoint gp = this.transform(point, frame, date);
  408.         final GeodeticPoint gpZero =
  409.                 new GeodeticPoint(gp.getLatitude(), gp.getLongitude(), 0);
  410.         final StaticTransform bodyToFrame =
  411.                 this.getBodyFrame().getStaticTransformTo(frame, date);
  412.         return bodyToFrame.transformPosition(this.transform(gpZero));
  413.     }

  414.     /**
  415.      * {@inheritDoc}
  416.      *
  417.      * <p> The intersection point is computed using a line search along the
  418.      * specified line. This is accurate when the geoid is slowly varying.
  419.      */
  420.     @Override
  421.     public <T extends CalculusFieldElement<T>> FieldGeodeticPoint<T> getIntersectionPoint(final FieldLine<T> lineInFrame,
  422.                                                                                       final FieldVector3D<T> closeInFrame,
  423.                                                                                       final Frame frame,
  424.                                                                                       final FieldAbsoluteDate<T> date) {

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

  435.         // set the line's direction so the solved for value is always positive
  436.         final FieldLine<T> line;
  437.         if (lineInBodyFrame.getAbscissa(close).getReal() < 0) {
  438.             line = lineInBodyFrame.revert();
  439.         } else {
  440.             line = lineInBodyFrame;
  441.         }

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

  457.         // line search function
  458.         final CalculusFieldUnivariateFunction<T> heightFunction = z -> {
  459.             try {
  460.                 final FieldGeodeticPoint<T> geodetic =
  461.                         transform(line.pointAt(z), bodyFrame, date);
  462.                 return geodetic.getAltitude();
  463.             } catch (OrekitException e) {
  464.                 // due to frame transform -> re-throw
  465.                 throw new RuntimeException(e);
  466.             }
  467.         };

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

  489.     @Override
  490.     public TimeStampedPVCoordinates projectToGround(
  491.             final TimeStampedPVCoordinates pv,
  492.             final Frame frame) {
  493.         throw new UnsupportedOperationException();
  494.     }

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

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

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

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

  622. }