StateMapper.java

  1. /* Copyright 2002-2013 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.propagation.integration;

  18. import org.orekit.attitudes.AttitudeProvider;
  19. import org.orekit.errors.OrekitException;
  20. import org.orekit.frames.Frame;
  21. import org.orekit.orbits.OrbitType;
  22. import org.orekit.orbits.PositionAngle;
  23. import org.orekit.propagation.SpacecraftState;
  24. import org.orekit.time.AbsoluteDate;

  25. /** This class maps between raw double elements and {@link SpacecraftState} instances.
  26.  * @author Luc Maisonobe
  27.  * @since 6.0
  28.  */
  29. public abstract class StateMapper {

  30.     /** Reference date. */
  31.     private final AbsoluteDate referenceDate;

  32.     /** Propagation orbit type. */
  33.     private final OrbitType orbitType;

  34.     /** Position angle type. */
  35.     private final PositionAngle angleType;

  36.     /** Attitude provider. */
  37.     private final AttitudeProvider attitudeProvider;

  38.     /** Central attraction coefficient. */
  39.     private final double mu;

  40.     /** Inertial frame. */
  41.     private final Frame frame;

  42.     /** Simple constructor.
  43.      * <p>
  44.      * The position parameter type is meaningful only if {@link
  45.      * #getOrbitType() propagation orbit type}
  46.      * support it. As an example, it is not meaningful for propagation
  47.      * in {@link OrbitType#CARTESIAN Cartesian} parameters.
  48.      * </p>
  49.      * @param referenceDate reference date
  50.      * @param mu central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>)
  51.      * @param orbitType orbit type to use for mapping
  52.      * @param positionAngleType angle type to use for propagation
  53.      * @param attitudeProvider attitude provider
  54.      * @param frame inertial frame
  55.      */
  56.     protected StateMapper(final AbsoluteDate referenceDate, final double mu,
  57.                           final OrbitType orbitType, final PositionAngle positionAngleType,
  58.                           final AttitudeProvider attitudeProvider, final Frame frame) {
  59.         this.referenceDate    = referenceDate;
  60.         this.mu               = mu;
  61.         this.orbitType        = orbitType;
  62.         this.angleType        = positionAngleType;
  63.         this.attitudeProvider = attitudeProvider;
  64.         this.frame            = frame;
  65.     }

  66.     /** Get reference date.
  67.      * @return reference date
  68.      */
  69.     public AbsoluteDate getReferenceDate() {
  70.         return referenceDate;
  71.     }

  72.     /** Get propagation parameter type.
  73.      * @return orbit type used for propagation
  74.      */
  75.     public OrbitType getOrbitType() {
  76.         return orbitType;
  77.     }

  78.     /** Set position angle type.
  79.      */
  80.     public void setPositionAngleType() {
  81.     }

  82.     /** Get propagation parameter type.
  83.      * @return angle type to use for propagation
  84.      */
  85.     public PositionAngle getPositionAngleType() {
  86.         return angleType;
  87.     }

  88.     /** Get the central attraction coefficient &mu;.
  89.      * @return mu central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>)
  90.      */
  91.     public double getMu() {
  92.         return mu;
  93.     }

  94.     /** Get the inertial frame.
  95.      * @return inertial frame
  96.      */
  97.     public Frame getFrame() {
  98.         return frame;
  99.     }

  100.     /** Get the attitude provider.
  101.      * @return attitude provider
  102.      */
  103.     public AttitudeProvider getAttitudeProvider() {
  104.         return attitudeProvider;
  105.     }

  106.     /** Map the raw double time offset to a date.
  107.      * @param t date offset
  108.      * @return date
  109.      */
  110.     public AbsoluteDate mapDoubleToDate(final double t) {
  111.         return referenceDate.shiftedBy(t);
  112.     }

  113.     /** Map a date to a raw double time offset.
  114.      * @param date date
  115.      * @return time offset
  116.      */
  117.     public double mapDateToDouble(final AbsoluteDate date) {
  118.         return date.durationFrom(referenceDate);
  119.     }

  120.     /** Map the raw double components to a spacecraft state.
  121.      * @param t date offset
  122.      * @param y state components
  123.      * @return spacecraft state
  124.      * @exception OrekitException if array is inconsistent or cannot be mapped
  125.      */
  126.     public abstract SpacecraftState mapArrayToState(final double t, final double[] y)
  127.         throws OrekitException;

  128.     /** Map a spacecraft state to raw double components.
  129.      * @param state state to map
  130.      * @param y placeholder where to put the components
  131.      * @exception OrekitException if state is inconsistent or cannot be mapped
  132.      */
  133.     public abstract void mapStateToArray(final SpacecraftState state, final double[] y)
  134.         throws OrekitException;

  135. }