KeplerianPropagatorBuilder.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.conversion;

  18. import java.util.ArrayList;
  19. import java.util.Collection;

  20. import org.apache.commons.math3.exception.util.LocalizedFormats;
  21. import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
  22. import org.apache.commons.math3.ode.AbstractParameterizable;
  23. import org.orekit.errors.OrekitException;
  24. import org.orekit.frames.Frame;
  25. import org.orekit.orbits.KeplerianOrbit;
  26. import org.orekit.propagation.Propagator;
  27. import org.orekit.propagation.analytical.KeplerianPropagator;
  28. import org.orekit.time.AbsoluteDate;
  29. import org.orekit.utils.PVCoordinates;

  30. /** Builder for Keplerian propagator.
  31.  * @author Pascal Parraud
  32.  * @since 6.0
  33.  */
  34. public class KeplerianPropagatorBuilder extends AbstractParameterizable
  35.                                         implements PropagatorBuilder {

  36.     /** Central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>). */
  37.     private final double mu;

  38.     /** Frame in which the orbit is propagated. */
  39.     private final Frame frame;

  40.     /** List of the free parameters names. */
  41.     private Collection<String> freeParameters;

  42.     /** Build a new instance.
  43.      * @param mu central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>)
  44.      * @param frame the frame in which the orbit is propagated
  45.      * (<em>must</em> be a {@link Frame#isPseudoInertial pseudo-inertial frame})
  46.      */
  47.     public KeplerianPropagatorBuilder(final double mu,
  48.                                       final Frame frame) {
  49.         this.mu    = mu;
  50.         this.frame = frame;
  51.     }

  52.     /** {@inheritDoc} */
  53.     public Propagator buildPropagator(final AbsoluteDate date, final double[] parameters)
  54.         throws OrekitException {

  55.         if (parameters.length != (freeParameters.size() + 6)) {
  56.             throw OrekitException.createIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH);
  57.         }

  58.         final KeplerianOrbit orb = new KeplerianOrbit(new PVCoordinates(new Vector3D(parameters[0],
  59.                                                                                      parameters[1],
  60.                                                                                      parameters[2]),
  61.                                                                         new Vector3D(parameters[3],
  62.                                                                                      parameters[4],
  63.                                                                                      parameters[5])),
  64.                                                       frame, date, mu);

  65.         return new KeplerianPropagator(orb);
  66.     }

  67.     /** {@inheritDoc} */
  68.     public Frame getFrame() {
  69.         return frame;
  70.     }

  71.     /** {@inheritDoc} */
  72.     public void setFreeParameters(final Collection<String> parameters)
  73.         throws IllegalArgumentException {
  74.         freeParameters = new ArrayList<String>();
  75.         for (String name : parameters) {
  76.             complainIfNotSupported(name);
  77.         }
  78.         freeParameters.addAll(parameters);
  79.     }

  80.     /** {@inheritDoc} */
  81.     public double getParameter(final String name)
  82.         throws IllegalArgumentException {
  83.         return 0;
  84.     }

  85.     /** {@inheritDoc} */
  86.     public void setParameter(final String name, final double value)
  87.         throws IllegalArgumentException {
  88.     }

  89. }