InertialProvider.java

  1. /* Copyright 2002-2018 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.attitudes;

  18. import org.hipparchus.RealFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.Rotation;
  20. import org.orekit.errors.OrekitException;
  21. import org.orekit.frames.FieldTransform;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.frames.FramesFactory;
  24. import org.orekit.frames.Transform;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.time.FieldAbsoluteDate;
  27. import org.orekit.utils.FieldPVCoordinatesProvider;
  28. import org.orekit.utils.PVCoordinatesProvider;


  29. /**
  30.  * This class handles an inertial attitude provider.
  31.  * <p>Instances of this class are guaranteed to be immutable.</p>
  32.  * @author Luc Maisonobe
  33.  */
  34. public class InertialProvider implements AttitudeProvider {


  35.     /** Dummy attitude provider, perfectly aligned with the EME2000 frame. */
  36.     public static final InertialProvider EME2000_ALIGNED =
  37.         new InertialProvider(Rotation.IDENTITY);

  38.     /** Serializable UID. */
  39.     private static final long serialVersionUID = -818658655669855332L;

  40.     /** Fixed satellite frame. */
  41.     private final Frame satelliteFrame;

  42.     /** Creates new instance.
  43.      * @param rotation rotation from EME2000 to the desired satellite frame
  44.      */
  45.     public InertialProvider(final Rotation rotation) {
  46.         satelliteFrame =
  47.             new Frame(FramesFactory.getEME2000(), new Transform(AbsoluteDate.J2000_EPOCH, rotation),
  48.                       null, false);
  49.     }

  50.     /** {@inheritDoc} */
  51.     public Attitude getAttitude(final PVCoordinatesProvider pvProv,
  52.                                 final AbsoluteDate date, final Frame frame)
  53.         throws OrekitException {
  54.         final Transform t = frame.getTransformTo(satelliteFrame, date);
  55.         return new Attitude(date, frame, t.getRotation(), t.getRotationRate(), t.getRotationAcceleration());
  56.     }

  57.     /** {@inheritDoc} */
  58.     public <T extends RealFieldElement<T>>FieldAttitude<T> getAttitude(final FieldPVCoordinatesProvider<T> pvProv,
  59.                                                                        final FieldAbsoluteDate<T> date, final Frame frame)
  60.         throws OrekitException {
  61.         final FieldTransform<T> t = frame.getTransformTo(satelliteFrame, date);
  62.         return new FieldAttitude<>(date, frame, t.getRotation(), t.getRotationRate(), t.getRotationAcceleration());
  63.     }

  64. }