Maneuver.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.adm.apm;

  18. import java.util.Arrays;

  19. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  20. import org.orekit.files.ccsds.definitions.FrameFacade;
  21. import org.orekit.files.ccsds.section.CommentsContainer;
  22. import org.orekit.time.AbsoluteDate;

  23. /**
  24.  * Maneuver in an APM file.
  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 Bryan Cazabonne
  40.  * @since 10.2
  41.  */
  42. public class Maneuver extends CommentsContainer {

  43.     /** Epoch of start of maneuver . */
  44.     private AbsoluteDate epochStart;

  45.     /** Coordinate system for the torque vector. */
  46.     private FrameFacade frame;

  47.     /** Duration (value is 0 for impulsive maneuver). */
  48.     private double duration;

  49.     /** Torque vector (N.m). */
  50.     private final double[] torque;

  51.     /** Mass change during maneuver (kg).
  52.      * @since 12.0
  53.      */
  54.     private double deltaMass;

  55.     /**
  56.      * Simple constructor.
  57.      */
  58.     public Maneuver() {
  59.         duration  = Double.NaN;
  60.         torque    = new double[3];
  61.         deltaMass = Double.NaN;
  62.         Arrays.fill(torque, Double.NaN);
  63.     }

  64.     /** {@inheritDoc} */
  65.     @Override
  66.     public void validate(final double version) {
  67.         super.validate(version);
  68.         checkNotNull(epochStart, ManeuverKey.MAN_EPOCH_START.name());
  69.         checkNotNaN(duration,    ManeuverKey.MAN_DURATION.name());
  70.         checkNotNull(frame,      ManeuverKey.MAN_REF_FRAME.name());
  71.         checkNotNaN(torque[0],   ManeuverKey.MAN_TOR_1.name());
  72.         checkNotNaN(torque[1],   ManeuverKey.MAN_TOR_2.name());
  73.         checkNotNaN(torque[2],   ManeuverKey.MAN_TOR_3.name());
  74.     }

  75.     /**
  76.      * Get epoch start.
  77.      * @return epoch start
  78.      */
  79.     public AbsoluteDate getEpochStart() {
  80.         return epochStart;
  81.     }

  82.     /**
  83.      * Set epoch start.
  84.      * @param epochStart epoch start
  85.      */
  86.     public void setEpochStart(final AbsoluteDate epochStart) {
  87.         refuseFurtherComments();
  88.         this.epochStart = epochStart;
  89.     }

  90.     /**
  91.      * Get Coordinate system for the torque vector.
  92.      * @return coordinate system for the torque vector
  93.      */
  94.     public FrameFacade getFrame() {
  95.         return frame;
  96.     }

  97.     /**
  98.      * Set Coordinate system for the torque vector.
  99.      * @param frame coordinate system for the torque vector
  100.      */
  101.     public void setFrame(final FrameFacade frame) {
  102.         refuseFurtherComments();
  103.         this.frame = frame;
  104.     }

  105.     /**
  106.      * Get duration (value is 0 for impulsive maneuver).
  107.      * @return duration (value is 0 for impulsive maneuver)
  108.      */
  109.     public double getDuration() {
  110.         return duration;
  111.     }

  112.     /**
  113.      * Set duration (value is 0 for impulsive maneuver).
  114.      * @param duration duration (value is 0 for impulsive maneuver)
  115.      */
  116.     public void setDuration(final double duration) {
  117.         refuseFurtherComments();
  118.         this.duration = duration;
  119.     }

  120.     /**
  121.      * Get the torque vector (N.m).
  122.      * @return torque vector
  123.      */
  124.     public Vector3D getTorque() {
  125.         return new Vector3D(torque);
  126.     }

  127.     /**
  128.      * Set the torque vector (N.m).
  129.      * @param index vector component index (counting from 0)
  130.      * @param value component value
  131.      */
  132.     public void setTorque(final int index, final double value) {
  133.         refuseFurtherComments();
  134.         this.torque[index] = value;
  135.     }

  136.     /**
  137.      * Get mass change during maneuver.
  138.      * @return mass change during maneuver (kg, negative)
  139.      * @since 12.0
  140.      */
  141.     public double getDeltaMass() {
  142.         return deltaMass;
  143.     }

  144.     /**
  145.      * Set mass change during maneuver.
  146.      * @param deltaMass mass change during maneuver (kg)
  147.      * @since 12.0
  148.      */
  149.     public void setDeltaMass(final double deltaMass) {
  150.         refuseFurtherComments();
  151.         this.deltaMass = deltaMass;
  152.     }

  153. }