1 /* Copyright 2022-2025 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.apm;
19
20 import org.hipparchus.linear.MatrixUtils;
21 import org.hipparchus.linear.RealMatrix;
22 import org.orekit.files.ccsds.definitions.FrameFacade;
23 import org.orekit.files.ccsds.ndm.CommonPhysicalProperties;
24
25 /** Inertia.
26 * @author Luc Maisonobe
27 * @since 12.0
28 */
29 public class Inertia extends CommonPhysicalProperties {
30
31 /** Inertia reference frame. */
32 private FrameFacade frame;
33
34 /** Inertia matrix. */
35 private RealMatrix inertiaMatrix;
36
37 /** Simple constructor.
38 */
39 public Inertia() {
40 inertiaMatrix = MatrixUtils.createRealMatrix(new double[][] {
41 { Double.NaN, Double.NaN, Double.NaN },
42 { Double.NaN, Double.NaN, Double.NaN },
43 { Double.NaN, Double.NaN, Double.NaN }
44 });
45 }
46
47 /** {@inheritDoc} */
48 @Override
49 public void validate(final double version) {
50 super.validate(version);
51 if (version >= 2.0) {
52 checkNotNull(frame, InertiaKey.INERTIA_REF_FRAME.name());
53 }
54 checkNotNaN(inertiaMatrix.getEntry(0, 0), InertiaKey.IXX.name());
55 checkNotNaN(inertiaMatrix.getEntry(1, 1), InertiaKey.IYY.name());
56 checkNotNaN(inertiaMatrix.getEntry(2, 2), InertiaKey.IZZ.name());
57 checkNotNaN(inertiaMatrix.getEntry(0, 1), InertiaKey.IXY.name());
58 checkNotNaN(inertiaMatrix.getEntry(0, 2), InertiaKey.IXZ.name());
59 checkNotNaN(inertiaMatrix.getEntry(1, 2), InertiaKey.IYZ.name());
60 }
61
62 /** Set frame in which inertia is specified.
63 * @param frame frame in which inertia is specified
64 */
65 public void setFrame(final FrameFacade frame) {
66 this.frame = frame;
67 }
68
69 /** Get frame in which inertia is specified.
70 * @return frame in which inertia is specified
71 */
72 public FrameFacade getFrame() {
73 return frame;
74 }
75
76 /** Get the inertia matrix.
77 * @return the inertia matrix
78 */
79 public RealMatrix getInertiaMatrix() {
80 return inertiaMatrix;
81 }
82
83 /** Set an entry in the inertia matrix.
84 * <p>
85 * Both I(j, k) and I(k, j) are set.
86 * </p>
87 * @param j row index (must be between 0 and 3 (inclusive)
88 * @param k column index (must be between 0 and 3 (inclusive)
89 * @param entry value of the matrix entry
90 */
91 public void setInertiaMatrixEntry(final int j, final int k, final double entry) {
92 refuseFurtherComments();
93 inertiaMatrix.setEntry(j, k, entry);
94 inertiaMatrix.setEntry(k, j, entry);
95 }
96
97 }