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  
19  import org.hipparchus.geometry.euclidean.threed.Vector3D;
20  import org.orekit.files.ccsds.ndm.odm.StateVectorKey;
21  import org.orekit.files.ccsds.section.CommentsContainer;
22  
23  /**
24   * Container for state vector data.
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 Melina Vanel
40   * @since 11.2
41   */
42  public class StateVector extends CommentsContainer {
43  
44      /** Object Position Vector X component. */
45      private double x;
46  
47      /** Object Position Vector Y component. */
48      private double y;
49  
50      /** Object Position Vector Z component. */
51      private double z;
52  
53      /** Object Velocity Vector X component. */
54      private double xDot;
55  
56      /** Object Velocity Vector Y component. */
57      private double yDot;
58  
59      /** Object Velocity Vector Z component. */
60      private double zDot;
61  
62      /** Simple constructor.
63       */
64      public StateVector() {
65          x         = Double.NaN;
66          y         = Double.NaN;
67          z         = Double.NaN;
68          xDot      = Double.NaN;
69          yDot      = Double.NaN;
70          zDot      = Double.NaN;
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public void validate(final double version) {
76          super.validate(version);
77          checkNotNaN(x, StateVectorKey.X.name());
78          checkNotNaN(y, StateVectorKey.Y.name());
79          checkNotNaN(z, StateVectorKey.Z.name());
80          checkNotNaN(xDot, StateVectorKey.X_DOT.name());
81          checkNotNaN(yDot, StateVectorKey.Y_DOT.name());
82          checkNotNaN(zDot, StateVectorKey.Z_DOT.name());
83  
84      }
85  
86      /**
87       * Set object Position Vector X component.
88       * @param X object Position Vector X component (in m)
89       */
90      public void setX(final double X) {
91          refuseFurtherComments();
92          this.x = X;
93      }
94  
95      /**
96       * Set object Position Vector Y component.
97       * @param Y object Position Vector Y component (in m)
98       */
99      public void setY(final double Y) {
100         refuseFurtherComments();
101         this.y = Y;
102     }
103 
104     /**
105      * Set object Position Vector Z component.
106      * @param Z object Position Vector Z component (in m)
107      */
108     public void setZ(final double Z) {
109         refuseFurtherComments();
110         this.z = Z;
111     }
112 
113     /**
114      * Set object Velocity Vector X component.
115      * @param Xdot object Velocity Vector X component (in m/s)
116      */
117     public void setXdot(final double Xdot) {
118         refuseFurtherComments();
119         this.xDot = Xdot;
120     }
121 
122     /**
123      * Set object Velocity Vector Y component.
124      * @param Ydot object Velocity Vector Y component (in m/s)
125      */
126     public void setYdot(final double Ydot) {
127         refuseFurtherComments();
128         this.yDot = Ydot;
129     }
130 
131     /**
132      * Set object Velocity Vector Z component.
133      * @param Zdot object Velocity Vector Z component (in m/s)
134      */
135     public void setZdot(final double Zdot) {
136         refuseFurtherComments();
137         this.zDot = Zdot;
138     }
139 
140     /**
141      * Get object Position Vector.
142      * @return object Position Vector (in m)
143      */
144     public Vector3D getPositionVector() {
145         return new Vector3D(x, y, z);
146     }
147 
148     /**
149      * Get object Velocity Vector.
150      * @return object Velocity Vector (in m/s)
151      */
152     public Vector3D getVelocityVector() {
153         return new Vector3D(xDot, yDot, zDot);
154     }
155 
156 
157 }