Inertia.java

  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. package org.orekit.files.ccsds.ndm.adm.apm;

  18. import org.hipparchus.linear.MatrixUtils;
  19. import org.hipparchus.linear.RealMatrix;
  20. import org.orekit.files.ccsds.definitions.FrameFacade;
  21. import org.orekit.files.ccsds.ndm.CommonPhysicalProperties;

  22. /** Inertia.
  23.  * @author Luc Maisonobe
  24.  * @since 12.0
  25.  */
  26. public class Inertia extends CommonPhysicalProperties {

  27.     /** Inertia reference frame. */
  28.     private FrameFacade frame;

  29.     /** Inertia matrix. */
  30.     private RealMatrix inertiaMatrix;

  31.     /** Simple constructor.
  32.      */
  33.     public Inertia() {
  34.         inertiaMatrix = MatrixUtils.createRealMatrix(new double[][] {
  35.             { Double.NaN, Double.NaN, Double.NaN },
  36.             { Double.NaN, Double.NaN, Double.NaN },
  37.             { Double.NaN, Double.NaN, Double.NaN }
  38.         });
  39.     }

  40.     /** {@inheritDoc} */
  41.     @Override
  42.     public void validate(final double version) {
  43.         super.validate(version);
  44.         if (version >= 2.0) {
  45.             checkNotNull(frame, InertiaKey.INERTIA_REF_FRAME.name());
  46.         }
  47.         checkNotNaN(inertiaMatrix.getEntry(0, 0), InertiaKey.IXX.name());
  48.         checkNotNaN(inertiaMatrix.getEntry(1, 1), InertiaKey.IYY.name());
  49.         checkNotNaN(inertiaMatrix.getEntry(2, 2), InertiaKey.IZZ.name());
  50.         checkNotNaN(inertiaMatrix.getEntry(0, 1), InertiaKey.IXY.name());
  51.         checkNotNaN(inertiaMatrix.getEntry(0, 2), InertiaKey.IXZ.name());
  52.         checkNotNaN(inertiaMatrix.getEntry(1, 2), InertiaKey.IYZ.name());
  53.     }

  54.     /** Set frame in which inertia is specified.
  55.      * @param frame frame in which inertia is specified
  56.      */
  57.     public void setFrame(final FrameFacade frame) {
  58.         this.frame = frame;
  59.     }

  60.     /** Get frame in which inertia is specified.
  61.      * @return frame in which inertia is specified
  62.      */
  63.     public FrameFacade getFrame() {
  64.         return frame;
  65.     }

  66.     /** Get the inertia matrix.
  67.      * @return the inertia matrix
  68.      */
  69.     public RealMatrix getInertiaMatrix() {
  70.         return inertiaMatrix;
  71.     }

  72.     /** Set an entry in the inertia matrix.
  73.      * <p>
  74.      * Both I(j, k) and I(k, j) are set.
  75.      * </p>
  76.      * @param j row index (must be between 0 and 3 (inclusive)
  77.      * @param k column index (must be between 0 and 3 (inclusive)
  78.      * @param entry value of the matrix entry
  79.      */
  80.     public void setInertiaMatrixEntry(final int j, final int k, final double entry) {
  81.         refuseFurtherComments();
  82.         inertiaMatrix.setEntry(j, k, entry);
  83.         inertiaMatrix.setEntry(k, j, entry);
  84.     }

  85. }