1   /* Copyright 2002-2024 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  
18  package org.orekit.files.ccsds.ndm.adm.acm;
19  
20  import org.hipparchus.geometry.euclidean.threed.Vector3D;
21  import org.hipparchus.linear.MatrixUtils;
22  import org.hipparchus.linear.RealMatrix;
23  import org.orekit.files.ccsds.definitions.FrameFacade;
24  import org.orekit.files.ccsds.section.CommentsContainer;
25  import org.orekit.time.AbsoluteDate;
26  
27  /** Spacecraft physical properties.
28   * @author Luc Maisonobe
29   * @since 12.0
30   */
31  public class AttitudePhysicalProperties extends CommentsContainer {
32  
33      /** Drag coefficient. */
34      private double dragCoefficient;
35  
36      /** Total mass at T₀. */
37      private double wetMass;
38  
39      /** Mass without propellant. */
40      private double dryMass;
41  
42      /** Reference frame for center of pressure. */
43      private FrameFacade centerOfPressureReferenceFrame;
44  
45      /** Location of center of pressure. */
46      private Vector3D centerOfPressure;
47  
48      /** Reference frame for inertia. */
49      private FrameFacade inertiaReferenceFrame;
50  
51      /** Inertia matrix. */
52      private RealMatrix inertiaMatrix;
53  
54      /** Simple constructor.
55       * @param epochT0 T0 epoch from file metadata
56       */
57      public AttitudePhysicalProperties(final AbsoluteDate epochT0) {
58          dragCoefficient = Double.NaN;
59          wetMass         = Double.NaN;
60          dryMass         = Double.NaN;
61          inertiaMatrix   = MatrixUtils.createRealMatrix(3, 3);
62      }
63  
64      /** {@inheritDoc} */
65      @Override
66      public void validate(final double version) {
67          super.validate(version);
68          if (centerOfPressureReferenceFrame != null) {
69              checkNotNull(centerOfPressure, AttitudePhysicalPropertiesKey.CP.name());
70          }
71      }
72  
73      /** Get the drag coefficient.
74       * @return the drag coefficient
75       */
76      public double getDragCoefficient() {
77          return dragCoefficient;
78      }
79  
80      /** Set the the drag coefficient.
81       * @param dragCoefficient the drag coefficient
82       */
83      public void setDragCoefficient(final double dragCoefficient) {
84          refuseFurtherComments();
85          this.dragCoefficient = dragCoefficient;
86      }
87  
88      /** Get the total mass at T₀.
89       * @return total mass at T₀
90       */
91      public double getWetMass() {
92          return wetMass;
93      }
94  
95      /** Set the total mass at T₀.
96       * @param wetMass total mass at T₀
97       */
98      public void setWetMass(final double wetMass) {
99          refuseFurtherComments();
100         this.wetMass = wetMass;
101     }
102 
103     /** Get the mass without propellant.
104      * @return mass without propellant
105      */
106     public double getDryMass() {
107         return dryMass;
108     }
109 
110     /** Set the mass without propellant.
111      * @param dryMass mass without propellant
112      */
113     public void setDryMass(final double dryMass) {
114         refuseFurtherComments();
115         this.dryMass = dryMass;
116     }
117 
118     /** Get reference frame for center of pressure.
119      * @return reference frame for center of pressure
120      */
121     public FrameFacade getCenterOfPressureReferenceFrame() {
122         return centerOfPressureReferenceFrame;
123     }
124 
125     /** Set reference frame for center of pressure.
126      * @param centerOfPressureReferenceFrame reference frame for center of pressure
127      */
128     public void setCenterOfPressureReferenceFrame(final FrameFacade centerOfPressureReferenceFrame) {
129         this.centerOfPressureReferenceFrame = centerOfPressureReferenceFrame;
130     }
131 
132     /** Get the location of center of pressure.
133      * @return location of center of pressure
134      */
135     public Vector3D getCenterOfPressure() {
136         return centerOfPressure;
137     }
138 
139     /** Set the location of center of pressure.
140      * @param centerOfPressure location of center of pressure
141      */
142     public void setCenterOfPressure(final Vector3D centerOfPressure) {
143         this.centerOfPressure = centerOfPressure;
144     }
145 
146     /** Get reference frame for inertia.
147      * @return reference frame for inertia
148      */
149     public FrameFacade getInertiaReferenceFrame() {
150         return inertiaReferenceFrame;
151     }
152 
153     /** Set reference frame for inertia.
154      * @param inertiaReferenceFrame reference frame for inertia
155      */
156     public void setInertiaReferenceFrame(final FrameFacade inertiaReferenceFrame) {
157         this.inertiaReferenceFrame = inertiaReferenceFrame;
158     }
159 
160     /** Get the inertia matrix.
161      * @return the inertia matrix
162      */
163     public RealMatrix getInertiaMatrix() {
164         return inertiaMatrix;
165     }
166 
167     /** Set an entry in the inertia matrix.
168      * <p>
169      * Both I(j, k) and I(k, j) are set.
170      * </p>
171      * @param j row index (must be between 0 and 3 (inclusive)
172      * @param k column index (must be between 0 and 3 (inclusive)
173      * @param entry value of the matrix entry
174      */
175     public void setInertiaMatrixEntry(final int j, final int k, final double entry) {
176         refuseFurtherComments();
177         inertiaMatrix.setEntry(j, k, entry);
178         inertiaMatrix.setEntry(k, j, entry);
179     }
180 
181 }