SpacecraftFrame.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.frames;

  18. import java.io.Externalizable;
  19. import java.io.IOException;
  20. import java.io.NotSerializableException;
  21. import java.io.ObjectInput;
  22. import java.io.ObjectOutput;

  23. import org.orekit.errors.OrekitException;
  24. import org.orekit.propagation.Propagator;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.utils.PVCoordinates;
  27. import org.orekit.utils.PVCoordinatesProvider;


  28. /** Spacecraft frame.
  29.  * <p>Frame associated to a satellite body, taking into account orbit and attitude.</p>
  30.  * <p>
  31.  * Use of this frame is not recommended, and it will probably be withdrawn in a future version.
  32.  * In many cases, rather than using this frame and its {@link #getTransformTo(Frame, AbsoluteDate)
  33.  * getTransformTo} method, users should directly get a {@link Transform} using
  34.  * {@link org.orekit.propagation.SpacecraftState#toTransform()}.
  35.  * </p>
  36.  * <p>
  37.  * Note that despite it extends {@link Frame}, this frame is <em>NOT</em> serializable,
  38.  * as it relies on {@link Propagator}.
  39.  * </p>
  40.  * @deprecated as of 6.0 replaced by {@link org.orekit.propagation.SpacecraftState#toTransform()}
  41.  * @author Luc Maisonobe
  42.  */
  43. @Deprecated
  44. public class SpacecraftFrame extends Frame implements PVCoordinatesProvider {

  45.     /** Serializable UID. */
  46.     private static final long serialVersionUID = 6012707827832395314L;

  47.     /** Simple constructor.
  48.      * @param propagator orbit/attitude propagator computing spacecraft state evolution
  49.      * @param name name of the frame
  50.      */
  51.     public SpacecraftFrame(final Propagator propagator, final String name) {
  52.         super(propagator.getFrame(), new LocalProvider(propagator), name, false);
  53.     }

  54.     /** Get the underlying propagator.
  55.      * @return underlying propagator
  56.      */
  57.     public Propagator getPropagator() {
  58.         return ((LocalProvider) getTransformProvider()).getPropagator();
  59.     }

  60.     /** Get the {@link PVCoordinates} of the spacecraft frame origin in the selected frame.
  61.      * @param date current date
  62.      * @param frame the frame where to define the position
  63.      * @return position/velocity of the spacecraft frame origin (m and m/s)
  64.      * @exception OrekitException if position cannot be computed in given frame
  65.      */
  66.     public PVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame)
  67.         throws OrekitException {
  68.         return getPropagator().getPVCoordinates(date, frame);
  69.     }

  70.     /** Local provider for transforms. */
  71.     private static class LocalProvider implements TransformProvider, Externalizable {

  72.         /** Serializable UID. */
  73.         private static final long serialVersionUID = 386815086579675823L;

  74.         /** Propagator to use. */
  75.         private final transient Propagator propagator;

  76.         /** Simple constructor.
  77.          * @param propagator orbit/attitude propagator computing spacecraft state evolution
  78.          */
  79.         public LocalProvider(final Propagator propagator) {
  80.             this.propagator = propagator;
  81.         }

  82.         /** {@inheritDoc} */
  83.         public Transform getTransform(final AbsoluteDate date) throws OrekitException {
  84.             return propagator.propagate(date).toTransform();
  85.         }

  86.         /** Get the underlying propagator.
  87.          * @return underlying propagator
  88.          */
  89.         public Propagator getPropagator() {
  90.             return propagator;
  91.         }

  92.         /** {@inheritDoc} */
  93.         public void readExternal(final ObjectInput input) throws IOException {
  94.             throw new NotSerializableException();
  95.         }

  96.         /** {@inheritDoc} */
  97.         public void writeExternal(final ObjectOutput output) throws IOException {
  98.             throw new NotSerializableException();
  99.         }

  100.     }

  101. }