EclipticProvider.java

  1. /* Contributed in the public domain.
  2.  * Licensed to CS Systèmes d'Information (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.frames;

  18. import java.io.Serializable;

  19. import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
  20. import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention;
  21. import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
  22. import org.orekit.errors.OrekitException;
  23. import org.orekit.errors.OrekitInternalError;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.time.TimeFunction;
  26. import org.orekit.utils.IERSConventions;

  27. /**
  28.  * An inertial frame aligned with the ecliptic.
  29.  * <p>
  30.  * The IAU defines the ecliptic as "the plane perpendicular to the mean heliocentric
  31.  * orbital angular momentum vector of the Earth-Moon barycentre in the BCRS (IAU 2006
  32.  * Resolution B1)." The +z axis is aligned with the angular momentum vector, and the +x
  33.  * axis is aligned with +x axis of {@link FramesFactory#getMOD(IERSConventions) MOD}.
  34.  * </p>
  35.  *
  36.  * <p>
  37.  * This implementation agrees with the JPL 406 ephemerides to within 0.5 arc seconds.
  38.  * </p>
  39.  *
  40.  * @since 7.0
  41.  */
  42. public class EclipticProvider implements TransformProvider {

  43.     /** Serializable UID. */
  44.     private static final long serialVersionUID = 20140516L;

  45.     /** IERS conventions. */
  46.     private final IERSConventions conventions;

  47.     /** the obliquity of the ecliptic, in radians as a function of time. */
  48.     private final transient TimeFunction<Double> obliquity;

  49.     /**
  50.      * Create a transform provider from MOD to an ecliptically aligned frame.
  51.      * @param conventions IERS conventions
  52.      * @throws OrekitException if the mean obliquity of the ecliptic function can not be
  53.      *                         loaded.
  54.      */
  55.     public EclipticProvider(final IERSConventions conventions) throws OrekitException {
  56.         this.conventions = conventions;
  57.         this.obliquity   = conventions.getMeanObliquityFunction();
  58.     }

  59.     @Override
  60.     public Transform getTransform(final AbsoluteDate date) throws OrekitException {
  61.         //mean obliquity of date
  62.         final double epsA = obliquity.value(date);
  63.         return new Transform(date, new Rotation(Vector3D.MINUS_I, epsA, RotationConvention.VECTOR_OPERATOR));
  64.     }

  65.     /** Replace the instance with a data transfer object for serialization.
  66.      * <p>
  67.      * This intermediate class serializes only the frame key.
  68.      * </p>
  69.      * @return data transfer object that will be serialized
  70.      */
  71.     private Object writeReplace() {
  72.         return new DataTransferObject(conventions);
  73.     }

  74.     /** Internal class used only for serialization. */
  75.     private static class DataTransferObject implements Serializable {

  76.         /** Serializable UID. */
  77.         private static final long serialVersionUID = 20140516L;

  78.         /** IERS conventions. */
  79.         private final IERSConventions conventions;

  80.         /** Simple constructor.
  81.          * @param conventions IERS conventions
  82.          */
  83.         DataTransferObject(final IERSConventions conventions) {
  84.             this.conventions = conventions;
  85.         }

  86.         /** Replace the deserialized data transfer object with a {@link EclipticProvider}.
  87.          * @return replacement {@link EclipticProvider}
  88.          */
  89.         private Object readResolve() {
  90.             try {
  91.                 // retrieve a transform
  92.                 return new EclipticProvider(conventions);
  93.             } catch (OrekitException oe) {
  94.                 throw new OrekitInternalError(oe);
  95.             }
  96.         }

  97.     }

  98. }