1   /* Copyright 2022-2026 Luc Maisonobe
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  
19  import org.orekit.files.ccsds.definitions.CcsdsFrameMapper;
20  import org.orekit.files.ccsds.definitions.FrameFacade;
21  import org.orekit.files.ccsds.ndm.adm.AttitudeEndpoints;
22  import org.orekit.files.ccsds.section.CommentsContainer;
23  import org.orekit.frames.Frame;
24  
25  /**
26   * Container for Attitude Parameter Message data lines.
27   * <p>
28   * Beware that the Orekit getters and setters all rely on SI units. The parsers
29   * and writers take care of converting these SI units into CCSDS mandatory units.
30   * The {@link org.orekit.utils.units.Unit Unit} class provides useful
31   * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
32   * {@link org.orekit.utils.units.Unit#toSI(double) toSI} methods in case the callers
33   * already use CCSDS units instead of the API SI units. The general-purpose
34   * {@link org.orekit.utils.units.Unit Unit} class (without an 's') and the
35   * CCSDS-specific {@link org.orekit.files.ccsds.definitions.Units Units} class
36   * (with an 's') also provide some predefined units. These predefined units and the
37   * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
38   * {@link org.orekit.utils.units.Unit#toSI(double) toSI} conversion methods are indeed
39   * what the parsers and writers use for the conversions.
40   * </p>
41   * @author Luc Maisonobe
42   * @since 12.0
43   */
44  public class AngularVelocity extends CommentsContainer {
45  
46      /** Endpoints (i.e. frames A, B and their relationship). */
47      private final AttitudeEndpoints endpoints;
48  
49      /** The frame in which angular velocities are specified. */
50      private FrameFacade frame;
51  
52      /** Angular velocity around X axis (rad/s). */
53      private double angVelX;
54  
55      /** Angular velocity around Y axis (rad/s). */
56      private double angVelY;
57  
58      /** Angular velocity around Z axis (rad/s). */
59      private double angVelZ;
60  
61      /**
62       * Simple constructor.
63       *
64       * @param frameMapper for creating a {@link Frame}.
65       * @since 13.1.5
66       */
67      public AngularVelocity(final CcsdsFrameMapper frameMapper) {
68          endpoints = new AttitudeEndpoints(frameMapper);
69          frame     = null;
70          angVelX   = Double.NaN;
71          angVelY   = Double.NaN;
72          angVelZ   = Double.NaN;
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public void validate(final double version) {
78          super.validate(version);
79          endpoints.checkMandatoryEntriesExceptExternalFrame(version,
80                                                             AngularVelocityKey.REF_FRAME_A,
81                                                             AngularVelocityKey.REF_FRAME_B,
82                                                             null);
83          endpoints.checkExternalFrame(AngularVelocityKey.REF_FRAME_A, AngularVelocityKey.REF_FRAME_B);
84          checkNotNull(frame, AngularVelocityKey.ANGVEL_FRAME.name());
85          checkNotNaN(angVelX, AngularVelocityKey.ANGVEL_X.name());
86          checkNotNaN(angVelY, AngularVelocityKey.ANGVEL_Y.name());
87          checkNotNaN(angVelZ, AngularVelocityKey.ANGVEL_Z.name());
88      }
89  
90      /** Get the endpoints (i.e. frames A, B and their relationship).
91       * @return endpoints
92       */
93      public AttitudeEndpoints getEndpoints() {
94          return endpoints;
95      }
96  
97      /** Set frame in which angular velocities are specified.
98       * @param frame frame in which angular velocities are specified
99       */
100     public void setFrame(final FrameFacade frame) {
101         this.frame = frame;
102     }
103 
104     /** Get frame in which angular velocities are specified.
105      * @return frame in which angular velocities are specified
106      */
107     public FrameFacade getFrame() {
108         return frame;
109     }
110 
111     /** Get the angular velocity around X axis (rad/s).
112      * @return angular velocity around X axis (rad/s)
113      */
114     public double getAngVelX() {
115         return angVelX;
116     }
117 
118     /** Set the angular velocity around X axis (rad/s).
119      * @param angVelX angular velocity around X axis (rad/s)
120      */
121     public void setAngVelX(final double angVelX) {
122         refuseFurtherComments();
123         this.angVelX = angVelX;
124     }
125 
126     /** Get the angular velocity around Y axis (rad/s).
127      * @return angular velocity around Y axis (rad/s)
128      */
129     public double getAngVelY() {
130         return angVelY;
131     }
132 
133     /** Set the angular velocity around Z axis (rad/s).
134      * @param angVelZ angular velocity around Z axis (rad/s)
135      */
136     public void setAngVelZ(final double angVelZ) {
137         refuseFurtherComments();
138         this.angVelZ = angVelZ;
139     }
140 
141     /** Get the angular velocity around Z axis (rad/s).
142      * @return angular velocity around Z axis (rad/s)
143      */
144     public double getAngVelZ() {
145         return angVelZ;
146     }
147 
148     /** Set the angular velocity around Y axis (rad/s).
149      * @param angVelY angular velocity around Y axis (rad/s)
150      */
151     public void setAngVelY(final double angVelY) {
152         refuseFurtherComments();
153         this.angVelY = angVelY;
154     }
155 
156 }