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 19 import org.orekit.attitudes.AttitudeProvider; 20 import org.orekit.errors.OrekitException; 21 import org.orekit.frames.Frame; 22 import org.orekit.orbits.OrbitType; 23 import org.orekit.orbits.PositionAngle; 24 import org.orekit.propagation.SpacecraftState; 25 import org.orekit.time.AbsoluteDate; 26 27 /** This class maps between raw double elements and {@link SpacecraftState} instances. 28 * @author Luc Maisonobe 29 * @since 6.0 30 */ 31 public abstract class StateMapper { 32 33 /** Reference date. */ 34 private final AbsoluteDate referenceDate; 35 36 /** Propagation orbit type. */ 37 private final OrbitType orbitType; 38 39 /** Position angle type. */ 40 private final PositionAngle angleType; 41 42 /** Attitude provider. */ 43 private final AttitudeProvider attitudeProvider; 44 45 /** Central attraction coefficient. */ 46 private final double mu; 47 48 /** Inertial frame. */ 49 private final Frame frame; 50 51 /** Simple constructor. 52 * <p> 53 * The position parameter type is meaningful only if {@link 54 * #getOrbitType() propagation orbit type} 55 * support it. As an example, it is not meaningful for propagation 56 * in {@link OrbitType#CARTESIAN Cartesian} parameters. 57 * </p> 58 * @param referenceDate reference date 59 * @param mu central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>) 60 * @param orbitType orbit type to use for mapping 61 * @param positionAngleType angle type to use for propagation 62 * @param attitudeProvider attitude provider 63 * @param frame inertial frame 64 */ 65 protected StateMapper(final AbsoluteDate referenceDate, final double mu, 66 final OrbitType orbitType, final PositionAngle positionAngleType, 67 final AttitudeProvider attitudeProvider, final Frame frame) { 68 this.referenceDate = referenceDate; 69 this.mu = mu; 70 this.orbitType = orbitType; 71 this.angleType = positionAngleType; 72 this.attitudeProvider = attitudeProvider; 73 this.frame = frame; 74 } 75 76 /** Get reference date. 77 * @return reference date 78 */ 79 public AbsoluteDate getReferenceDate() { 80 return referenceDate; 81 } 82 83 /** Get propagation parameter type. 84 * @return orbit type used for propagation 85 */ 86 public OrbitType getOrbitType() { 87 return orbitType; 88 } 89 90 /** Set position angle type. 91 */ 92 public void setPositionAngleType() { 93 } 94 95 /** Get propagation parameter type. 96 * @return angle type to use for propagation 97 */ 98 public PositionAngle getPositionAngleType() { 99 return angleType; 100 } 101 102 /** Get the central attraction coefficient μ. 103 * @return mu central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>) 104 */ 105 public double getMu() { 106 return mu; 107 } 108 109 /** Get the inertial frame. 110 * @return inertial frame 111 */ 112 public Frame getFrame() { 113 return frame; 114 } 115 116 /** Get the attitude provider. 117 * @return attitude provider 118 */ 119 public AttitudeProvider getAttitudeProvider() { 120 return attitudeProvider; 121 } 122 123 /** Map the raw double time offset to a date. 124 * @param t date offset 125 * @return date 126 */ 127 public AbsoluteDate mapDoubleToDate(final double t) { 128 return referenceDate.shiftedBy(t); 129 } 130 131 /** Map a date to a raw double time offset. 132 * @param date date 133 * @return time offset 134 */ 135 public double mapDateToDouble(final AbsoluteDate date) { 136 return date.durationFrom(referenceDate); 137 } 138 139 /** Map the raw double components to a spacecraft state. 140 * @param t date offset 141 * @param y state components 142 * @return spacecraft state 143 * @exception OrekitException if array is inconsistent or cannot be mapped 144 */ 145 public abstract SpacecraftState mapArrayToState(final double t, final double[] y) 146 throws OrekitException; 147 148 /** Map a spacecraft state to raw double components. 149 * @param state state to map 150 * @param y placeholder where to put the components 151 * @exception OrekitException if state is inconsistent or cannot be mapped 152 */ 153 public abstract void mapStateToArray(final SpacecraftState state, final double[] y) 154 throws OrekitException; 155 156 }