KeplerianElements.java

  1. /* Copyright 2002-2025 CS GROUP
  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.files.ccsds.ndm.odm;

  18. import org.orekit.files.ccsds.section.CommentsContainer;
  19. import org.orekit.files.ccsds.section.Data;
  20. import org.orekit.frames.Frame;
  21. import org.orekit.orbits.KeplerianOrbit;
  22. import org.orekit.orbits.PositionAngleType;
  23. import org.orekit.time.AbsoluteDate;

  24. /** Container for Keplerian elements.
  25.  * <p>
  26.  * Beware that the Orekit getters and setters all rely on SI units. The parsers
  27.  * and writers take care of converting these SI units into CCSDS mandatory units.
  28.  * The {@link org.orekit.utils.units.Unit Unit} class provides useful
  29.  * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
  30.  * {@link org.orekit.utils.units.Unit#toSI(double) toSI} methods in case the callers
  31.  * already use CCSDS units instead of the API SI units. The general-purpose
  32.  * {@link org.orekit.utils.units.Unit Unit} class (without an 's') and the
  33.  * CCSDS-specific {@link org.orekit.files.ccsds.definitions.Units Units} class
  34.  * (with an 's') also provide some predefined units. These predefined units and the
  35.  * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
  36.  * {@link org.orekit.utils.units.Unit#toSI(double) toSI} conversion methods are indeed
  37.  * what the parsers and writers use for the conversions.
  38.  * </p>
  39.  * @author sports
  40.  * @since 6.1
  41.  */
  42. public class KeplerianElements extends CommentsContainer implements Data {

  43.     /** Epoch of state vector and optional Keplerian elements. */
  44.     private AbsoluteDate epoch;

  45.     /** Orbit semi-major axis (m). */
  46.     private double a;

  47.     /** Mean motion (the Keplerian Mean motion in rad/s).
  48.      * <p>
  49.      * Used in OMM instead of semi-major axis if MEAN_ELEMENT_THEORY = SGP/SGP4.
  50.      * </p>
  51.      */
  52.     private double meanMotion;

  53.     /** Orbit eccentricity. */
  54.     private double e;

  55.     /** Orbit inclination (rad). */
  56.     private double i;

  57.     /** Orbit right ascension of ascending node (rad). */
  58.     private double raan;

  59.     /** Orbit argument of pericenter (rad). */
  60.     private double pa;

  61.     /** Orbit anomaly (rad). */
  62.     private double anomaly;

  63.     /** Orbit anomaly type (mean or true). */
  64.     private PositionAngleType anomalyType;

  65.     /** Gravitational coefficient. */
  66.     private double mu;

  67.     /** Simple constructor.
  68.      */
  69.     public KeplerianElements() {
  70.         a          = Double.NaN;
  71.         meanMotion =  Double.NaN;
  72.         e          = Double.NaN;
  73.         i          = Double.NaN;
  74.         raan       = Double.NaN;
  75.         pa         = Double.NaN;
  76.         anomaly    = Double.NaN;
  77.         mu         = Double.NaN;
  78.     }

  79.     /** {@inheritDoc}
  80.      * <p>
  81.      * We check neither semi-major axis nor mean motion here,
  82.      * they must be checked separately in OPM and OMM parsers
  83.      * </p>
  84.      */
  85.     @Override
  86.     public void validate(final double version) {
  87.         super.validate(version);
  88.         checkNotNull(epoch,  StateVectorKey.EPOCH.name());
  89.         checkNotNaN(e,       KeplerianElementsKey.ECCENTRICITY.name());
  90.         checkNotNaN(i,       KeplerianElementsKey.INCLINATION.name());
  91.         checkNotNaN(raan,    KeplerianElementsKey.RA_OF_ASC_NODE.name());
  92.         checkNotNaN(pa,      KeplerianElementsKey.ARG_OF_PERICENTER.name());
  93.         checkNotNaN(anomaly, KeplerianElementsKey.MEAN_ANOMALY.name());
  94.     }

  95.     /** Get epoch of state vector, Keplerian elements and covariance matrix data.
  96.      * @return epoch the epoch
  97.      */
  98.     public AbsoluteDate getEpoch() {
  99.         return epoch;
  100.     }

  101.     /** Set epoch of state vector, Keplerian elements and covariance matrix data.
  102.      * @param epoch the epoch to be set
  103.      */
  104.     public void setEpoch(final AbsoluteDate epoch) {
  105.         refuseFurtherComments();
  106.         this.epoch = epoch;
  107.     }

  108.     /** Get the orbit semi-major axis.
  109.      * @return the orbit semi-major axis
  110.      */
  111.     public double getA() {
  112.         return a;
  113.     }

  114.     /** Set the orbit semi-major axis.
  115.      * @param a the semi-major axis to be set
  116.      */
  117.     public void setA(final double a) {
  118.         refuseFurtherComments();
  119.         this.a = a;
  120.     }

  121.     /** Get the orbit mean motion.
  122.      * @return the orbit mean motion
  123.      */
  124.     public double getMeanMotion() {
  125.         return meanMotion;
  126.     }

  127.     /** Set the orbit mean motion.
  128.      * @param motion the mean motion to be set
  129.      */
  130.     public void setMeanMotion(final double motion) {
  131.         this.meanMotion = motion;
  132.     }

  133.     /** Get the orbit eccentricity.
  134.      * @return the orbit eccentricity
  135.      */
  136.     public double getE() {
  137.         return e;
  138.     }

  139.     /** Set the orbit eccentricity.
  140.      * @param e the eccentricity to be set
  141.      */
  142.     public void setE(final double e) {
  143.         refuseFurtherComments();
  144.         this.e = e;
  145.     }

  146.     /** Get the orbit inclination.
  147.      * @return the orbit inclination
  148.      */
  149.     public double getI() {
  150.         return i;
  151.     }

  152.     /**Set the orbit inclination.
  153.      * @param i the inclination to be set
  154.      */
  155.     public void setI(final double i) {
  156.         refuseFurtherComments();
  157.         this.i = i;
  158.     }

  159.     /** Get the orbit right ascension of ascending node.
  160.      * @return the orbit right ascension of ascending node
  161.      */
  162.     public double getRaan() {
  163.         return raan;
  164.     }

  165.     /** Set the orbit right ascension of ascending node.
  166.      * @param raan the right ascension of ascending node to be set
  167.      */
  168.     public void setRaan(final double raan) {
  169.         refuseFurtherComments();
  170.         this.raan = raan;
  171.     }

  172.     /** Get the orbit argument of pericenter.
  173.      * @return the orbit argument of pericenter
  174.      */
  175.     public double getPa() {
  176.         return pa;
  177.     }

  178.     /** Set the orbit argument of pericenter.
  179.      * @param pa the argument of pericenter to be set
  180.      */
  181.     public void setPa(final double pa) {
  182.         refuseFurtherComments();
  183.         this.pa = pa;
  184.     }

  185.     /** Get the orbit anomaly.
  186.      * @return the orbit anomaly
  187.      */
  188.     public double getAnomaly() {
  189.         return anomaly;
  190.     }

  191.     /** Set the orbit anomaly.
  192.      * @param anomaly the anomaly to be set
  193.      */
  194.     public void setAnomaly(final double anomaly) {
  195.         refuseFurtherComments();
  196.         this.anomaly = anomaly;
  197.     }

  198.     /** Get the type of anomaly (true or mean).
  199.      * @return the type of anomaly
  200.      */
  201.     public PositionAngleType getAnomalyType() {
  202.         return anomalyType;
  203.     }

  204.     /** Set the type of anomaly.
  205.      * @param anomalyType the type of anomaly to be set
  206.      */
  207.     public void setAnomalyType(final PositionAngleType anomalyType) {
  208.         refuseFurtherComments();
  209.         this.anomalyType = anomalyType;
  210.     }

  211.     /**
  212.      * Set the gravitational coefficient.
  213.      * @param mu the coefficient to be set
  214.      */
  215.     public void setMu(final double mu) {
  216.         refuseFurtherComments();
  217.         this.mu = mu;
  218.     }

  219.     /**
  220.      * Get the gravitational coefficient.
  221.      * @return gravitational coefficient
  222.      */
  223.     public double getMu() {
  224.         return mu;
  225.     }

  226.     /** Generate a keplerian orbit.
  227.      * @param frame inertial frame for orbit
  228.      * @return generated orbit
  229.      */
  230.     public KeplerianOrbit generateKeplerianOrbit(final Frame frame) {
  231.         return new KeplerianOrbit(a, e, i, pa, raan, anomaly, anomalyType, frame, epoch, mu);
  232.     }

  233. }