StateVector.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.cdm;

  18. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.orekit.files.ccsds.ndm.odm.StateVectorKey;
  20. import org.orekit.files.ccsds.section.CommentsContainer;

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

  41.     /** Object Position Vector X component. */
  42.     private double x;

  43.     /** Object Position Vector Y component. */
  44.     private double y;

  45.     /** Object Position Vector Z component. */
  46.     private double z;

  47.     /** Object Velocity Vector X component. */
  48.     private double xDot;

  49.     /** Object Velocity Vector Y component. */
  50.     private double yDot;

  51.     /** Object Velocity Vector Z component. */
  52.     private double zDot;

  53.     /** Simple constructor.
  54.      */
  55.     public StateVector() {
  56.         x         = Double.NaN;
  57.         y         = Double.NaN;
  58.         z         = Double.NaN;
  59.         xDot      = Double.NaN;
  60.         yDot      = Double.NaN;
  61.         zDot      = Double.NaN;
  62.     }

  63.     /** {@inheritDoc} */
  64.     @Override
  65.     public void validate(final double version) {
  66.         super.validate(version);
  67.         checkNotNaN(x, StateVectorKey.X.name());
  68.         checkNotNaN(y, StateVectorKey.Y.name());
  69.         checkNotNaN(z, StateVectorKey.Z.name());
  70.         checkNotNaN(xDot, StateVectorKey.X_DOT.name());
  71.         checkNotNaN(yDot, StateVectorKey.Y_DOT.name());
  72.         checkNotNaN(zDot, StateVectorKey.Z_DOT.name());

  73.     }

  74.     /**
  75.      * Set object Position Vector X component.
  76.      * @param X object Position Vector X component (in m)
  77.      */
  78.     public void setX(final double X) {
  79.         refuseFurtherComments();
  80.         this.x = X;
  81.     }

  82.     /**
  83.      * Set object Position Vector Y component.
  84.      * @param Y object Position Vector Y component (in m)
  85.      */
  86.     public void setY(final double Y) {
  87.         refuseFurtherComments();
  88.         this.y = Y;
  89.     }

  90.     /**
  91.      * Set object Position Vector Z component.
  92.      * @param Z object Position Vector Z component (in m)
  93.      */
  94.     public void setZ(final double Z) {
  95.         refuseFurtherComments();
  96.         this.z = Z;
  97.     }

  98.     /**
  99.      * Set object Velocity Vector X component.
  100.      * @param Xdot object Velocity Vector X component (in m/s)
  101.      */
  102.     public void setXdot(final double Xdot) {
  103.         refuseFurtherComments();
  104.         this.xDot = Xdot;
  105.     }

  106.     /**
  107.      * Set object Velocity Vector Y component.
  108.      * @param Ydot object Velocity Vector Y component (in m/s)
  109.      */
  110.     public void setYdot(final double Ydot) {
  111.         refuseFurtherComments();
  112.         this.yDot = Ydot;
  113.     }

  114.     /**
  115.      * Set object Velocity Vector Z component.
  116.      * @param Zdot object Velocity Vector Z component (in m/s)
  117.      */
  118.     public void setZdot(final double Zdot) {
  119.         refuseFurtherComments();
  120.         this.zDot = Zdot;
  121.     }

  122.     /**
  123.      * Get object Position Vector.
  124.      * @return object Position Vector (in m)
  125.      */
  126.     public Vector3D getPositionVector() {
  127.         return new Vector3D(x, y, z);
  128.     }

  129.     /**
  130.      * Get object Velocity Vector.
  131.      * @return object Velocity Vector (in m/s)
  132.      */
  133.     public Vector3D getVelocityVector() {
  134.         return new Vector3D(xDot, yDot, zDot);
  135.     }


  136. }