KeplerianElements.java

  1. /* Copyright 2002-2022 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.PositionAngle;
  23. import org.orekit.time.AbsoluteDate;

  24. /** Container for Keplerian elements.
  25.  * @author sports
  26.  * @since 6.1
  27.  */
  28. public class KeplerianElements extends CommentsContainer implements Data {

  29.     /** Epoch of state vector and optional Keplerian elements. */
  30.     private AbsoluteDate epoch;

  31.     /** Orbit semi-major axis (m). */
  32.     private double a;

  33.     /** Mean motion (the Keplerian Mean motion in rad/s).
  34.      * <p>
  35.      * Used in OMM instead of semi-major axis if MEAN_ELEMENT_THEORY = SGP/SGP4.
  36.      * </p>
  37.      */
  38.     private double meanMotion;

  39.     /** Orbit eccentricity. */
  40.     private double e;

  41.     /** Orbit inclination (rad). */
  42.     private double i;

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

  45.     /** Orbit argument of pericenter (rad). */
  46.     private double pa;

  47.     /** Orbit anomaly (rad). */
  48.     private double anomaly;

  49.     /** Orbit anomaly type (mean or true). */
  50.     private PositionAngle anomalyType;

  51.     /** Gravitational coefficient. */
  52.     private double mu;

  53.     /** Simple constructor.
  54.      */
  55.     public KeplerianElements() {
  56.         a          = Double.NaN;
  57.         meanMotion =  Double.NaN;
  58.         e          = Double.NaN;
  59.         i          = Double.NaN;
  60.         raan       = Double.NaN;
  61.         pa         = Double.NaN;
  62.         anomaly    = Double.NaN;
  63.         mu         = Double.NaN;
  64.     }

  65.     /** {@inheritDoc}
  66.      * <p>
  67.      * We check neither semi-major axis nor mean motion here,
  68.      * they must be checked separately in OPM and OMM parsers
  69.      * </p>
  70.      */
  71.     @Override
  72.     public void validate(final double version) {
  73.         super.validate(version);
  74.         checkNotNull(epoch,  StateVectorKey.EPOCH);
  75.         checkNotNaN(e,       KeplerianElementsKey.ECCENTRICITY);
  76.         checkNotNaN(i,       KeplerianElementsKey.INCLINATION);
  77.         checkNotNaN(raan,    KeplerianElementsKey.RA_OF_ASC_NODE);
  78.         checkNotNaN(pa,      KeplerianElementsKey.ARG_OF_PERICENTER);
  79.         checkNotNaN(anomaly, KeplerianElementsKey.MEAN_ANOMALY);
  80.     }

  81.     /** Get epoch of state vector, Keplerian elements and covariance matrix data.
  82.      * @return epoch the epoch
  83.      */
  84.     public AbsoluteDate getEpoch() {
  85.         return epoch;
  86.     }

  87.     /** Set epoch of state vector, Keplerian elements and covariance matrix data.
  88.      * @param epoch the epoch to be set
  89.      */
  90.     public void setEpoch(final AbsoluteDate epoch) {
  91.         refuseFurtherComments();
  92.         this.epoch = epoch;
  93.     }

  94.     /** Get the orbit semi-major axis.
  95.      * @return the orbit semi-major axis
  96.      */
  97.     public double getA() {
  98.         return a;
  99.     }

  100.     /** Set the orbit semi-major axis.
  101.      * @param a the semi-major axis to be set
  102.      */
  103.     public void setA(final double a) {
  104.         refuseFurtherComments();
  105.         this.a = a;
  106.     }

  107.     /** Get the orbit mean motion.
  108.      * @return the orbit mean motion
  109.      */
  110.     public double getMeanMotion() {
  111.         return meanMotion;
  112.     }

  113.     /** Set the orbit mean motion.
  114.      * @param motion the mean motion to be set
  115.      */
  116.     public void setMeanMotion(final double motion) {
  117.         this.meanMotion = motion;
  118.     }

  119.     /** Get the orbit eccentricity.
  120.      * @return the orbit eccentricity
  121.      */
  122.     public double getE() {
  123.         return e;
  124.     }

  125.     /** Set the orbit eccentricity.
  126.      * @param e the eccentricity to be set
  127.      */
  128.     public void setE(final double e) {
  129.         refuseFurtherComments();
  130.         this.e = e;
  131.     }

  132.     /** Get the orbit inclination.
  133.      * @return the orbit inclination
  134.      */
  135.     public double getI() {
  136.         return i;
  137.     }

  138.     /**Set the orbit inclination.
  139.      * @param i the inclination to be set
  140.      */
  141.     public void setI(final double i) {
  142.         refuseFurtherComments();
  143.         this.i = i;
  144.     }

  145.     /** Get the orbit right ascension of ascending node.
  146.      * @return the orbit right ascension of ascending node
  147.      */
  148.     public double getRaan() {
  149.         return raan;
  150.     }

  151.     /** Set the orbit right ascension of ascending node.
  152.      * @param raan the right ascension of ascending node to be set
  153.      */
  154.     public void setRaan(final double raan) {
  155.         refuseFurtherComments();
  156.         this.raan = raan;
  157.     }

  158.     /** Get the orbit argument of pericenter.
  159.      * @return the orbit argument of pericenter
  160.      */
  161.     public double getPa() {
  162.         return pa;
  163.     }

  164.     /** Set the orbit argument of pericenter.
  165.      * @param pa the argument of pericenter to be set
  166.      */
  167.     public void setPa(final double pa) {
  168.         refuseFurtherComments();
  169.         this.pa = pa;
  170.     }

  171.     /** Get the orbit anomaly.
  172.      * @return the orbit anomaly
  173.      */
  174.     public double getAnomaly() {
  175.         return anomaly;
  176.     }

  177.     /** Set the orbit anomaly.
  178.      * @param anomaly the anomaly to be set
  179.      */
  180.     public void setAnomaly(final double anomaly) {
  181.         refuseFurtherComments();
  182.         this.anomaly = anomaly;
  183.     }

  184.     /** Get the type of anomaly (true or mean).
  185.      * @return the type of anomaly
  186.      */
  187.     public PositionAngle getAnomalyType() {
  188.         return anomalyType;
  189.     }

  190.     /** Set the type of anomaly.
  191.      * @param anomalyType the type of anomaly to be set
  192.      */
  193.     public void setAnomalyType(final PositionAngle anomalyType) {
  194.         refuseFurtherComments();
  195.         this.anomalyType = anomalyType;
  196.     }

  197.     /**
  198.      * Set the gravitational coefficient.
  199.      * @param mu the coefficient to be set
  200.      */
  201.     public void setMu(final double mu) {
  202.         refuseFurtherComments();
  203.         this.mu = mu;
  204.     }

  205.     /**
  206.      * Get the gravitational coefficient.
  207.      * @return gravitational coefficient
  208.      */
  209.     public double getMu() {
  210.         return mu;
  211.     }

  212.     /** Generate a keplerian orbit.
  213.      * @param frame inertial frame for orbit
  214.      * @return generated orbit
  215.      */
  216.     public KeplerianOrbit generateKeplerianOrbit(final Frame frame) {
  217.         return new KeplerianOrbit(a, e, i, pa, raan, anomaly, anomalyType, frame, epoch, mu);
  218.     }

  219. }