SpinStabilized.java

  1. /* Copyright 2002-2024 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.adm.apm;

  18. import org.orekit.errors.OrekitException;
  19. import org.orekit.errors.OrekitMessages;
  20. import org.orekit.files.ccsds.ndm.adm.AttitudeEndpoints;
  21. import org.orekit.files.ccsds.section.CommentsContainer;

  22. /**
  23.  * Container for Attitude Parameter Message data lines.
  24.  * @author Bryan Cazabonne
  25.  * @since 10.2
  26.  */
  27. public class SpinStabilized extends CommentsContainer {

  28.     /** Endpoints (i.e. frames A, B and their relationship). */
  29.     private final AttitudeEndpoints endpoints;

  30.     /** Right ascension of spin axis vector (rad). */
  31.     private double spinAlpha;

  32.     /** Declination of the spin axis vector (rad). */
  33.     private double spinDelta;

  34.     /** Phase of the satellite about the spin axis (rad). */
  35.     private double spinAngle;

  36.     /** Angular velocity of satellite around spin axis (rad/s). */
  37.     private double spinAngleVel;

  38.     /** Nutation angle of spin axis (rad). */
  39.     private double nutation;

  40.     /** Body nutation period of the spin axis (s). */
  41.     private double nutationPer;

  42.     /** Inertial nutation phase (rad). */
  43.     private double nutationPhase;

  44.     /** Right ascension of angular momentum vector (rad).
  45.      * @since 12.0
  46.      */
  47.     private double momentumAlpha;

  48.     /** Declination of the angular momentum vector (rad).
  49.      * @since 12.0
  50.      */
  51.     private double momentumDelta;

  52.     /** Angular velocity of spin vector around the angular momentum vector (rad/s).
  53.      * @since 12.0
  54.      */
  55.     private double nutationVel;

  56.     /** Simple constructor.
  57.      */
  58.     public SpinStabilized() {
  59.         endpoints      = new AttitudeEndpoints();
  60.         spinAlpha      = Double.NaN;
  61.         spinDelta      = Double.NaN;
  62.         spinAngle      = Double.NaN;
  63.         spinAngleVel   = Double.NaN;
  64.         nutation       = Double.NaN;
  65.         nutationPer    = Double.NaN;
  66.         nutationPhase  = Double.NaN;
  67.         momentumAlpha  = Double.NaN;
  68.         momentumDelta  = Double.NaN;
  69.         nutationVel    = Double.NaN;
  70.     }

  71.     /** {@inheritDoc} */
  72.     @Override
  73.     public void validate(final double version) {
  74.         super.validate(version);
  75.         endpoints.checkMandatoryEntriesExceptExternalFrame(version,
  76.                                                            SpinStabilizedKey.SPIN_FRAME_A,
  77.                                                            SpinStabilizedKey.SPIN_FRAME_B,
  78.                                                            SpinStabilizedKey.SPIN_DIR);
  79.         endpoints.checkExternalFrame(SpinStabilizedKey.SPIN_FRAME_A, SpinStabilizedKey.SPIN_FRAME_B);
  80.         checkNotNaN(spinAlpha,    SpinStabilizedKey.SPIN_ALPHA.name());
  81.         checkNotNaN(spinDelta,    SpinStabilizedKey.SPIN_DELTA.name());
  82.         checkNotNaN(spinAngle,    SpinStabilizedKey.SPIN_ANGLE.name());
  83.         checkNotNaN(spinAngleVel, SpinStabilizedKey.SPIN_ANGLE_VEL.name());
  84.         if (Double.isNaN(nutation + nutationPer + nutationPhase)) {
  85.             // if at least one is NaN, all must be NaN (i.e. not initialized)
  86.             if (!(Double.isNaN(nutation) && Double.isNaN(nutationPer) && Double.isNaN(nutationPhase))) {
  87.                 throw new OrekitException(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY, "NUTATION*");
  88.             }
  89.         }
  90.         if (Double.isNaN(momentumAlpha + momentumDelta + nutationVel)) {
  91.             // if at least one is NaN, all must be NaN (i.e. not initialized)
  92.             if (!(Double.isNaN(momentumAlpha) && Double.isNaN(momentumDelta) && Double.isNaN(nutationVel))) {
  93.                 throw new OrekitException(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY, "MOMENTUM*/NUTATION_VEL");
  94.             }
  95.         }
  96.     }

  97.     /** Get the endpoints (i.e. frames A, B and their relationship).
  98.      * @return endpoints
  99.      */
  100.     public AttitudeEndpoints getEndpoints() {
  101.         return endpoints;
  102.     }

  103.     /**
  104.      * Get the right ascension of spin axis vector (rad).
  105.      * @return the right ascension of spin axis vector
  106.      */
  107.     public double getSpinAlpha() {
  108.         return spinAlpha;
  109.     }

  110.     /**
  111.      * Set the right ascension of spin axis vector (rad).
  112.      * @param spinAlpha value to be set
  113.      */
  114.     public void setSpinAlpha(final double spinAlpha) {
  115.         refuseFurtherComments();
  116.         this.spinAlpha = spinAlpha;
  117.     }

  118.     /**
  119.      * Get the declination of the spin axis vector (rad).
  120.      * @return the declination of the spin axis vector (rad).
  121.      */
  122.     public double getSpinDelta() {
  123.         return spinDelta;
  124.     }

  125.     /**
  126.      * Set the declination of the spin axis vector (rad).
  127.      * @param spinDelta value to be set
  128.      */
  129.     public void setSpinDelta(final double spinDelta) {
  130.         refuseFurtherComments();
  131.         this.spinDelta = spinDelta;
  132.     }

  133.     /**
  134.      * Get the phase of the satellite about the spin axis (rad).
  135.      * @return the phase of the satellite about the spin axis
  136.      */
  137.     public double getSpinAngle() {
  138.         return spinAngle;
  139.     }

  140.     /**
  141.      * Set the phase of the satellite about the spin axis (rad).
  142.      * @param spinAngle value to be set
  143.      */
  144.     public void setSpinAngle(final double spinAngle) {
  145.         refuseFurtherComments();
  146.         this.spinAngle = spinAngle;
  147.     }

  148.     /**
  149.      * Get the angular velocity of satellite around spin axis (rad/s).
  150.      * @return the angular velocity of satellite around spin axis
  151.      */
  152.     public double getSpinAngleVel() {
  153.         return spinAngleVel;
  154.     }

  155.     /**
  156.      * Set the angular velocity of satellite around spin axis (rad/s).
  157.      * @param spinAngleVel value to be set
  158.      */
  159.     public void setSpinAngleVel(final double spinAngleVel) {
  160.         refuseFurtherComments();
  161.         this.spinAngleVel = spinAngleVel;
  162.     }

  163.     /**
  164.      * Get the nutation angle of spin axis (rad).
  165.      * @return the nutation angle of spin axis
  166.      */
  167.     public double getNutation() {
  168.         return nutation;
  169.     }

  170.     /**
  171.      * Set the nutation angle of spin axis (rad).
  172.      * @param nutation the nutation angle to be set
  173.      */
  174.     public void setNutation(final double nutation) {
  175.         refuseFurtherComments();
  176.         this.nutation = nutation;
  177.     }

  178.     /**
  179.      * Get the body nutation period of the spin axis (s).
  180.      * @return the body nutation period of the spin axis
  181.      */
  182.     public double getNutationPeriod() {
  183.         return nutationPer;
  184.     }

  185.     /**
  186.      * Set the body nutation period of the spin axis (s).
  187.      * @param period the nutation period to be set
  188.      */
  189.     public void setNutationPeriod(final double period) {
  190.         refuseFurtherComments();
  191.         this.nutationPer = period;
  192.     }

  193.     /**
  194.      * Get the inertial nutation phase (rad).
  195.      * @return the inertial nutation phase
  196.      */
  197.     public double getNutationPhase() {
  198.         return nutationPhase;
  199.     }

  200.     /**
  201.      * Set the inertial nutation phase (rad).
  202.      * @param nutationPhase the nutation phase to be set
  203.      */
  204.     public void setNutationPhase(final double nutationPhase) {
  205.         refuseFurtherComments();
  206.         this.nutationPhase = nutationPhase;
  207.     }

  208.     /**
  209.      * Get the right ascension of angular momentum vector (rad).
  210.      * @return the right ascension of angular momentum vector
  211.      * @since 12.0
  212.      */
  213.     public double getMomentumAlpha() {
  214.         return momentumAlpha;
  215.     }

  216.     /**
  217.      * Set the right ascension of angular momentum vector (rad).
  218.      * @param momentumAlpha value to be set
  219.      * @since 12.0
  220.      */
  221.     public void setMomentumAlpha(final double momentumAlpha) {
  222.         refuseFurtherComments();
  223.         this.momentumAlpha = momentumAlpha;
  224.     }

  225.     /**
  226.      * Get the declination of the angular momentum vector (rad).
  227.      * @return the declination of the angular momentum vector (rad).
  228.      * @since 12.0
  229.      */
  230.     public double getMomentumDelta() {
  231.         return momentumDelta;
  232.     }

  233.     /**
  234.      * Set the declination of the angular momentum vector (rad).
  235.      * @param momentumDelta value to be set
  236.      * @since 12.0
  237.      */
  238.     public void setMomentumDelta(final double momentumDelta) {
  239.         refuseFurtherComments();
  240.         this.momentumDelta = momentumDelta;
  241.     }

  242.     /**
  243.      * Get the angular velocity of spin vector around angular momentum vector.
  244.      * @return angular velocity of spin vector around angular momentum vector (rad/s)
  245.      * @since 12.0
  246.      */
  247.     public double getNutationVel() {
  248.         return nutationVel;
  249.     }

  250.     /**
  251.      * Set the angular velocity of spin vector around angular momentum vector.
  252.      * @param nutationVel angular velocity of spin vector around angular momentum vector (rad/s)
  253.      * @since 12.0
  254.      */
  255.     public void setNutationVel(final double nutationVel) {
  256.         refuseFurtherComments();
  257.         this.nutationVel = nutationVel;
  258.     }

  259.     /** Check if the logical block includes nutation.
  260.      * @return true if logical block includes nutation
  261.      * @since 12.0
  262.      */
  263.     public boolean hasNutation() {
  264.         return !Double.isNaN(nutation + nutationPer + nutationPhase);
  265.     }

  266.     /** Check if the logical block includes momentum.
  267.      * @return true if logical block includes momentum
  268.      * @since 12.0
  269.      */
  270.     public boolean hasMomentum() {
  271.         return !Double.isNaN(momentumAlpha + momentumDelta + nutationVel);
  272.     }

  273. }