AttitudesSequence.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 java.util.ArrayList;
  19. import java.util.Arrays;
  20. import java.util.List;
  21. import java.util.Map;

  22. import org.hipparchus.Field;
  23. import org.hipparchus.RealFieldElement;
  24. import org.orekit.errors.OrekitException;
  25. import org.orekit.errors.OrekitMessages;
  26. import org.orekit.frames.Frame;
  27. import org.orekit.orbits.Orbit;
  28. import org.orekit.propagation.FieldPropagator;
  29. import org.orekit.propagation.FieldSpacecraftState;
  30. import org.orekit.propagation.Propagator;
  31. import org.orekit.propagation.SpacecraftState;
  32. import org.orekit.propagation.events.EventDetector;
  33. import org.orekit.propagation.events.FieldEventDetector;
  34. import org.orekit.propagation.events.handlers.EventHandler.Action;
  35. import org.orekit.propagation.events.handlers.FieldEventHandler;
  36. import org.orekit.time.AbsoluteDate;
  37. import org.orekit.time.FieldAbsoluteDate;
  38. import org.orekit.utils.AngularDerivativesFilter;
  39. import org.orekit.utils.FieldPVCoordinatesProvider;
  40. import org.orekit.utils.PVCoordinatesProvider;
  41. import org.orekit.utils.TimeSpanMap;
  42. import org.orekit.utils.TimeStampedAngularCoordinates;
  43. import org.orekit.utils.TimeStampedFieldAngularCoordinates;

  44. /** This classes manages a sequence of different attitude providers that are activated
  45.  * in turn according to switching events.
  46.  * <p>Only one attitude provider in the sequence is in an active state. When one of
  47.  * the switch event associated with the active provider occurs, the active provider becomes
  48.  * the one specified with the event. A simple example is a provider for the sun lighted part
  49.  * of the orbit and another provider for the eclipse time. When the sun lighted provider is active,
  50.  * the eclipse entry event is checked and when it occurs the eclipse provider is activated.
  51.  * When the eclipse provider is active, the eclipse exit event is checked and when it occurs
  52.  * the sun lighted provider is activated again. This sequence is a simple loop.</p>
  53.  * <p>An active attitude provider may have several switch events and next provider settings, leading
  54.  * to different activation patterns depending on which events are triggered first. An example
  55.  * of this feature is handling switches to safe mode if some contingency condition is met, in
  56.  * addition to the nominal switches that correspond to proper operations. Another example
  57.  * is handling of maneuver mode.<p>
  58.  * <p>
  59.  * Note that this attitude provider is stateful, it keeps in memory the sequence of active
  60.  * underlying providers with their switch dates and the transitions from one provider to
  61.  * the other. This implies that this provider should <em>not</em> be shared among different
  62.  * propagators at the same time, each propagator should use its own instance of this provider.
  63.  * </p>
  64.  * <p>
  65.  * The sequence kept in memory is reset when {@link #resetActiveProvider(AttitudeProvider)}
  66.  * is called, and only the specify provider is kept. The sequence is also partially
  67.  * reset each time a propagation starts. If a new propagation is started after a first
  68.  * propagation has been run, all the already computed switches that occur after propagation
  69.  * start for forward propagation or before propagation start for backward propagation will
  70.  * be erased. New switches will be computed and applied properly according to the new
  71.  * propagation settings. The already computed switches that are not in covered are kept
  72.  * in memory. This implies that if a propagation is interrupted and restarted in the
  73.  * same direction, then attitude switches will remain in place, ensuring that even if the
  74.  * interruption occurred in the middle of an attitude transition the second propagation will
  75.  * properly complete the transition that was started by the first propagator.
  76.  * </p>
  77.  * @author Luc Maisonobe
  78.  * @since 5.1
  79.  */
  80. public class AttitudesSequence implements AttitudeProvider {

  81.     /** Serializable UID. */
  82.     private static final long serialVersionUID = 20180326L;

  83.     /** Providers that have been activated. */
  84.     private TimeSpanMap<AttitudeProvider> activated;

  85.     /** Switching events list. */
  86.     private final List<Switch<?>> switches;

  87.     /** Constructor for an initially empty sequence.
  88.      */
  89.     public AttitudesSequence() {
  90.         activated = null;
  91.         switches  = new ArrayList<Switch<?>>();
  92.     }

  93.     /** Reset the active provider.
  94.      * <p>
  95.      * Calling this method clears all already seen switch history,
  96.      * so it should <em>not</em> be used during the propagation itself,
  97.      * it is intended to be used only at start
  98.      * </p>
  99.      * @param provider provider to activate
  100.      */
  101.     public void resetActiveProvider(final AttitudeProvider provider) {
  102.         activated = new TimeSpanMap<AttitudeProvider>(provider);
  103.     }

  104.     /** Register all wrapped switch events to the propagator.
  105.      * <p>
  106.      * This method must be called once before propagation, after the
  107.      * switching conditions have been set up by calls to {@link
  108.      * #addSwitchingCondition(AttitudeProvider, AttitudeProvider, EventDetector,
  109.      * boolean, boolean, double, AngularDerivativesFilter, SwitchHandler)
  110.      * addSwitchingCondition}.
  111.      * </p>
  112.      * @param propagator propagator that will handle the events
  113.      */
  114.     public void registerSwitchEvents(final Propagator propagator) {
  115.         for (final Switch<?> s : switches) {
  116.             propagator.addEventDetector(s);
  117.         }
  118.     }

  119.     /** Register all wrapped switch events to the propagator.
  120.      * <p>
  121.      * This method must be called once before propagation, after the
  122.      * switching conditions have been set up by calls to {@link
  123.      * #addSwitchingCondition(AttitudeProvider, AttitudeProvider, EventDetector,
  124.      * boolean, boolean, double, AngularDerivativesFilter, SwitchHandler)
  125.      * addSwitchingCondition}.
  126.      * </p>
  127.      * @param field field to which the elements belong
  128.      * @param propagator propagator that will handle the events
  129.      * @param <T> type of the field elements
  130.      */
  131.     public <T extends RealFieldElement<T>> void registerSwitchEvents(final Field<T> field, final FieldPropagator<T> propagator) {
  132.         for (final Switch<?> sw : switches) {
  133.             propagator.addEventDetector(new FieldEventDetector<T>() {

  134.                 /** {@inheritDoc} */
  135.                 @Override
  136.                 public void init(final FieldSpacecraftState<T> s0,
  137.                                  final FieldAbsoluteDate<T> t) throws OrekitException {
  138.                     sw.init(s0.toSpacecraftState(), t.toAbsoluteDate());
  139.                 }

  140.                 /** {@inheritDoc} */
  141.                 @Override
  142.                 public T g(final FieldSpacecraftState<T> s)
  143.                     throws OrekitException {
  144.                     return field.getZero().add(sw.g(s.toSpacecraftState()));
  145.                 }

  146.                 /** {@inheritDoc} */
  147.                 @Override
  148.                 public T getThreshold() {
  149.                     return field.getZero().add(sw.getThreshold());
  150.                 }

  151.                 /** {@inheritDoc} */
  152.                 @Override
  153.                 public T getMaxCheckInterval() {
  154.                     return field.getZero().add(sw.getMaxCheckInterval());
  155.                 }

  156.                 /** {@inheritDoc} */
  157.                 @Override
  158.                 public int getMaxIterationCount() {
  159.                     return sw.getMaxIterationCount();
  160.                 }

  161.                 /** {@inheritDoc} */
  162.                 @Override
  163.                 public FieldEventHandler.Action eventOccurred(final FieldSpacecraftState<T> s, final boolean increasing)
  164.                     throws OrekitException {
  165.                     switch(sw.eventOccurred(s.toSpacecraftState(), increasing)) {
  166.                         case STOP :
  167.                             return FieldEventHandler.Action.STOP;
  168.                         case RESET_DERIVATIVES :
  169.                             return FieldEventHandler.Action.RESET_DERIVATIVES;
  170.                         case RESET_STATE :
  171.                             return FieldEventHandler.Action.RESET_STATE;
  172.                         default :
  173.                             return FieldEventHandler.Action.CONTINUE;
  174.                     }
  175.                 }

  176.                 /** {@inheritDoc} */
  177.                 @Override
  178.                 public FieldSpacecraftState<T> resetState(final FieldSpacecraftState<T> oldState)
  179.                     throws OrekitException {
  180.                     return new FieldSpacecraftState<>(field, sw.resetState(oldState.toSpacecraftState()));
  181.                 }

  182.             });
  183.         }
  184.     }

  185.     /** Add a switching condition between two attitude providers.
  186.      * <p>
  187.      * The {@code past} and {@code future} attitude providers are defined with regard
  188.      * to the natural flow of time. This means that if the propagation is forward, the
  189.      * propagator will switch from {@code past} provider to {@code future} provider at
  190.      * event occurrence, but if the propagation is backward, the propagator will switch
  191.      * from {@code future} provider to {@code past} provider at event occurrence. The
  192.      * transition between the two attitude laws is not instantaneous, the switch event
  193.      * defines the start of the transition (i.e. when leaving the {@code past} attitude
  194.      * law and entering the interpolated transition law). The end of the transition
  195.      * (i.e. when leaving the interpolating transition law and entering the {@code future}
  196.      * attitude law) occurs at switch time plus {@code transitionTime}.
  197.      * </p>
  198.      * <p>
  199.      * An attitude provider may have several different switch events associated to
  200.      * it. Depending on which event is triggered, the appropriate provider is
  201.      * switched to.
  202.      * </p>
  203.      * <p>
  204.      * The switch events specified here must <em>not</em> be registered to the
  205.      * propagator directly. The proper way to register these events is to
  206.      * call {@link #registerSwitchEvents(Propagator)} once after all switching
  207.      * conditions have been set up. The reason for this is that the events will
  208.      * be wrapped before being registered.
  209.      * </p>
  210.      * <p>
  211.      * If the underlying detector has an event handler associated to it, this handler
  212.      * will be triggered (i.e. its {@link org.orekit.propagation.events.handlers.EventHandler#eventOccurred(SpacecraftState,
  213.      * EventDetector, boolean) eventOccurred} method will be called), <em>regardless</em>
  214.      * of the event really triggering an attitude switch or not. As an example, if an
  215.      * eclipse detector is used to switch from day to night attitude mode when entering
  216.      * eclipse, with {@code switchOnIncrease} set to {@code false} and {@code switchOnDecrease}
  217.      * set to {@code true}. Then a handler set directly at eclipse detector level would
  218.      * be triggered at both eclipse entry and eclipse exit, but attitude switch would
  219.      * occur <em>only</em> at eclipse entry. Note that for the sake of symmetry, the
  220.      * transition start and end dates should match for both forward and backward propagation.
  221.      * This implies that for backward propagation, we have to compensate for the {@code
  222.      * transitionTime} when looking for the event. An unfortunate consequence is that the
  223.      * {@link org.orekit.propagation.events.handlers.EventHandler#eventOccurred(SpacecraftState, EventDetector, boolean)
  224.      * eventOccurred} method may appear to be called out of sync with respect to the
  225.      * propagation (it will be called when propagator reaches transition end, despite it
  226.      * refers to transition start, as per {@code transitionTime} compensation), and if the
  227.      * method returns {@link Action#STOP}, it will stop at the end of the
  228.      * transition instead of at the start. For these reasons, it is not recommended to
  229.      * set up an event handler for events that are used to switch attitude. If an event
  230.      * handler is needed for other purposes, a second handler should be registered to
  231.      * the propagator rather than relying on the side effects of attitude switches.
  232.      * </p>
  233.      * <p>
  234.      * The smoothness of the transition between past and future attitude laws can be tuned
  235.      * using the {@code transitionTime} and {@code transitionFilter} parameters. The {@code
  236.      * transitionTime} parameter specifies how much time is spent to switch from one law to
  237.      * the other law. It should be larger than the event {@link EventDetector#getThreshold()
  238.      * convergence threshold} in order to ensure attitude continuity. The {@code
  239.      * transitionFilter} parameter specifies the attitude time derivatives that should match
  240.      * at the boundaries between past attitude law and transition law on one side, and
  241.      * between transition law and future law on the other side.
  242.      * {@link AngularDerivativesFilter#USE_R} means only the rotation should be identical,
  243.      * {@link AngularDerivativesFilter#USE_RR} means both rotation and rotation rate
  244.      * should be identical, {@link AngularDerivativesFilter#USE_RRA} means both rotation,
  245.      * rotation rate and rotation acceleration should be identical. During the transition,
  246.      * the attitude law is computed by interpolating between past attitude law at switch time
  247.      * and future attitude law at current intermediate time.
  248.      * </p>
  249.      * @param past attitude provider applicable for times in the switch event occurrence past
  250.      * @param future attitude provider applicable for times in the switch event occurrence future
  251.      * @param switchEvent event triggering the attitude providers switch
  252.      * @param switchOnIncrease if true, switch is triggered on increasing event
  253.      * @param switchOnDecrease if true, switch is triggered on decreasing event
  254.      * @param transitionTime duration of the transition between the past and future attitude laws
  255.      * @param transitionFilter specification of transition law time derivatives that
  256.      * should match past and future attitude laws
  257.      * @param handler handler to call for notifying when switch occurs (may be null)
  258.      * @param <T> class type for the switch event
  259.      * @exception OrekitException if transition time is shorter than event convergence threshold
  260.      * @since 7.1
  261.      */
  262.     public <T extends EventDetector> void addSwitchingCondition(final AttitudeProvider past,
  263.                                                                 final AttitudeProvider future,
  264.                                                                 final T switchEvent,
  265.                                                                 final boolean switchOnIncrease,
  266.                                                                 final boolean switchOnDecrease,
  267.                                                                 final double transitionTime,
  268.                                                                 final AngularDerivativesFilter transitionFilter,
  269.                                                                 final SwitchHandler handler)
  270.         throws OrekitException {

  271.         // safety check, for ensuring attitude continuity
  272.         if (transitionTime < switchEvent.getThreshold()) {
  273.             throw new OrekitException(OrekitMessages.TOO_SHORT_TRANSITION_TIME_FOR_ATTITUDES_SWITCH,
  274.                                       transitionTime, switchEvent.getThreshold());
  275.         }

  276.         // if it is the first switching condition, assume first active law is the past one
  277.         if (activated == null) {
  278.             resetActiveProvider(past);
  279.         }

  280.         // add the switching condition
  281.         switches.add(new Switch<T>(switchEvent, switchOnIncrease, switchOnDecrease,
  282.                                    past, future, transitionTime, transitionFilter, handler));

  283.     }

  284.     /** {@inheritDoc} */
  285.     public Attitude getAttitude(final PVCoordinatesProvider pvProv,
  286.                                 final AbsoluteDate date, final Frame frame)
  287.         throws OrekitException {
  288.         return activated.get(date).getAttitude(pvProv, date, frame);
  289.     }

  290.     /** {@inheritDoc} */
  291.     public <T extends RealFieldElement<T>> FieldAttitude<T> getAttitude(final FieldPVCoordinatesProvider<T> pvProv,
  292.                                                                         final FieldAbsoluteDate<T> date,
  293.                                                                         final Frame frame)
  294.         throws OrekitException {
  295.         return activated.get(date.toAbsoluteDate()).getAttitude(pvProv, date, frame);
  296.     }

  297.     /** Switch specification.
  298.      * @param <T> class type for the generic version
  299.      */
  300.     private class Switch<T extends EventDetector> implements EventDetector {

  301.         /** Serializable UID. */
  302.         private static final long serialVersionUID = 20150604L;

  303.         /** Event. */
  304.         private final T event;

  305.         /** Event direction triggering the switch. */
  306.         private final boolean switchOnIncrease;

  307.         /** Event direction triggering the switch. */
  308.         private final boolean switchOnDecrease;

  309.         /** Attitude provider applicable for times in the switch event occurrence past. */
  310.         private final AttitudeProvider past;

  311.         /** Attitude provider applicable for times in the switch event occurrence future. */
  312.         private final AttitudeProvider future;

  313.         /** Duration of the transition between the past and future attitude laws. */
  314.         private final double transitionTime;

  315.         /** Order at which the transition law time derivatives should match past and future attitude laws. */
  316.         private final AngularDerivativesFilter transitionFilter;

  317.         /** Handler to call for notifying when switch occurs (may be null). */
  318.         private final SwitchHandler switchHandler;

  319.         /** Propagation direction. */
  320.         private boolean forward;

  321.         /** Simple constructor.
  322.          * @param event event
  323.          * @param switchOnIncrease if true, switch is triggered on increasing event
  324.          * @param switchOnDecrease if true, switch is triggered on decreasing event
  325.          * otherwise switch is triggered on decreasing event
  326.          * @param past attitude provider applicable for times in the switch event occurrence past
  327.          * @param future attitude provider applicable for times in the switch event occurrence future
  328.          * @param transitionTime duration of the transition between the past and future attitude laws
  329.          * @param transitionFilter order at which the transition law time derivatives
  330.          * should match past and future attitude laws
  331.          * @param switchHandler handler to call for notifying when switch occurs (may be null)
  332.          */
  333.         Switch(final T event,
  334.                final boolean switchOnIncrease, final boolean switchOnDecrease,
  335.                final AttitudeProvider past, final AttitudeProvider future,
  336.                final double transitionTime, final AngularDerivativesFilter transitionFilter,
  337.                final SwitchHandler switchHandler) {
  338.             this.event            = event;
  339.             this.switchOnIncrease = switchOnIncrease;
  340.             this.switchOnDecrease = switchOnDecrease;
  341.             this.past             = past;
  342.             this.future           = future;
  343.             this.transitionTime   = transitionTime;
  344.             this.transitionFilter = transitionFilter;
  345.             this.switchHandler    = switchHandler;
  346.         }

  347.         /** {@inheritDoc} */
  348.         @Override
  349.         public double getThreshold() {
  350.             return event.getThreshold();
  351.         }

  352.         /** {@inheritDoc} */
  353.         @Override
  354.         public double getMaxCheckInterval() {
  355.             return event.getMaxCheckInterval();
  356.         }

  357.         /** {@inheritDoc} */
  358.         @Override
  359.         public int getMaxIterationCount() {
  360.             return event.getMaxIterationCount();
  361.         }

  362.         /** {@inheritDoc} */
  363.         public void init(final SpacecraftState s0,
  364.                          final AbsoluteDate t) throws OrekitException {

  365.             // reset the transition parameters (this will be done once for each switch,
  366.             //  despite doing it only once would have sufficient; its not really a problem)
  367.             forward = t.durationFrom(s0.getDate()) >= 0.0;
  368.             if (activated.getTransitions().size() > 1) {
  369.                 // remove transitions that will be overridden during upcoming propagation
  370.                 if (forward) {
  371.                     activated = activated.extractRange(AbsoluteDate.PAST_INFINITY, s0.getDate());
  372.                 } else {
  373.                     activated = activated.extractRange(s0.getDate(), AbsoluteDate.FUTURE_INFINITY);
  374.                 }
  375.             }

  376.             // initialize the underlying event
  377.             event.init(s0, t);

  378.         }

  379.         /** {@inheritDoc} */
  380.         public double g(final SpacecraftState s)
  381.             throws OrekitException {
  382.             return event.g(forward ? s : s.shiftedBy(-transitionTime));
  383.         }

  384.         /** {@inheritDoc} */
  385.         public Action eventOccurred(final SpacecraftState s, final boolean increasing)
  386.             throws OrekitException {

  387.             final AbsoluteDate date = s.getDate();
  388.             if (activated.get(date) == (forward ? past : future) &&
  389.                 ((increasing && switchOnIncrease) || (!increasing && switchOnDecrease))) {

  390.                 if (forward) {

  391.                     // prepare transition
  392.                     final AbsoluteDate transitionEnd = date.shiftedBy(transitionTime);
  393.                     activated.addValidAfter(new TransitionProvider(s.getAttitude(), transitionEnd), date);

  394.                     // prepare future law after transition
  395.                     activated.addValidAfter(future, transitionEnd);

  396.                     // notify about the switch
  397.                     if (switchHandler != null) {
  398.                         switchHandler.switchOccurred(past, future, s);
  399.                     }

  400.                     return event.eventOccurred(s, increasing);

  401.                 } else {

  402.                     // estimate state at transition start, according to the past attitude law
  403.                     final Orbit     sOrbit    = s.getOrbit().shiftedBy(-transitionTime);
  404.                     final Attitude  sAttitude = past.getAttitude(sOrbit, sOrbit.getDate(), sOrbit.getFrame());
  405.                     SpacecraftState sState    = new SpacecraftState(sOrbit, sAttitude, s.getMass());
  406.                     for (final Map.Entry<String, double[]> entry : s.getAdditionalStates().entrySet()) {
  407.                         sState = sState.addAdditionalState(entry.getKey(), entry.getValue());
  408.                     }

  409.                     // prepare transition
  410.                     activated.addValidBefore(new TransitionProvider(sAttitude, date), date);

  411.                     // prepare past law before transition
  412.                     activated.addValidBefore(past, sOrbit.getDate());

  413.                     // notify about the switch
  414.                     if (switchHandler != null) {
  415.                         switchHandler.switchOccurred(future, past, sState);
  416.                     }

  417.                     return event.eventOccurred(sState, increasing);

  418.                 }

  419.             } else {
  420.                 // trigger the underlying event despite no attitude switch occurred
  421.                 return event.eventOccurred(s, increasing);
  422.             }

  423.         }

  424.         /** {@inheritDoc} */
  425.         @Override
  426.         public SpacecraftState resetState(final SpacecraftState oldState)
  427.             throws OrekitException {
  428.             // delegate to underlying event
  429.             return event.resetState(oldState);
  430.         }

  431.         /** Provider for transition phases.
  432.          * @since 9.2
  433.          */
  434.         private class TransitionProvider implements AttitudeProvider {

  435.             /** Serializable UID. */
  436.             private static final long serialVersionUID = 20180326L;

  437.             /** Attitude at preceding transition. */
  438.             private final Attitude transitionPreceding;

  439.             /** Date of final switch to following attitude law. */
  440.             private final AbsoluteDate transitionEnd;

  441.             /** Simple constructor.
  442.              * @param transitionPreceding attitude at preceding transition
  443.              * @param transitionEnd date of final switch to following attitude law
  444.              */
  445.             TransitionProvider(final Attitude transitionPreceding, final AbsoluteDate transitionEnd) {
  446.                 this.transitionPreceding = transitionPreceding;
  447.                 this.transitionEnd       = transitionEnd;
  448.             }

  449.             /** {@inheritDoc} */
  450.             public Attitude getAttitude(final PVCoordinatesProvider pvProv,
  451.                                         final AbsoluteDate date, final Frame frame)
  452.                 throws OrekitException {

  453.                 // interpolate between the two boundary attitudes
  454.                 final TimeStampedAngularCoordinates start =
  455.                                 transitionPreceding.withReferenceFrame(frame).getOrientation();
  456.                 final TimeStampedAngularCoordinates end =
  457.                                 future.getAttitude(pvProv, transitionEnd, frame).getOrientation();
  458.                 final TimeStampedAngularCoordinates interpolated =
  459.                                 TimeStampedAngularCoordinates.interpolate(date, transitionFilter,
  460.                                                                           Arrays.asList(start, end));

  461.                 return new Attitude(frame, interpolated);

  462.             }

  463.             /** {@inheritDoc} */
  464.             public <S extends RealFieldElement<S>> FieldAttitude<S> getAttitude(final FieldPVCoordinatesProvider<S> pvProv,
  465.                                                                                 final FieldAbsoluteDate<S> date,
  466.                                                                                 final Frame frame)
  467.                                                                                                 throws OrekitException {

  468.                 // interpolate between the two boundary attitudes
  469.                 final TimeStampedFieldAngularCoordinates<S> start =
  470.                                 new TimeStampedFieldAngularCoordinates<>(date.getField(),
  471.                                                                          transitionPreceding.withReferenceFrame(frame).getOrientation());
  472.                 final TimeStampedFieldAngularCoordinates<S> end =
  473.                                 future.getAttitude(pvProv,
  474.                                                    new FieldAbsoluteDate<>(date.getField(), transitionEnd),
  475.                                                    frame).getOrientation();
  476.                 final TimeStampedFieldAngularCoordinates<S> interpolated =
  477.                                 TimeStampedFieldAngularCoordinates.interpolate(date, transitionFilter,
  478.                                                                                Arrays.asList(start, end));

  479.                 return new FieldAttitude<>(frame, interpolated);
  480.             }

  481.         }

  482.     }

  483.     /** Interface for attitude switch notifications.
  484.      * <p>
  485.      * This interface is intended to be implemented by users who want to be
  486.      * notified when an attitude switch occurs.
  487.      * </p>
  488.      * @since 7.1
  489.      */
  490.     public interface SwitchHandler {

  491.         /** Method called when attitude is switched from one law to another law.
  492.          * @param preceding attitude law used preceding the switch (i.e. in the past
  493.          * of the switch event for a forward propagation, or in the future
  494.          * of the switch event for a backward propagation)
  495.          * @param following attitude law used following the switch (i.e. in the future
  496.          * of the switch event for a forward propagation, or in the past
  497.          * of the switch event for a backward propagation)
  498.          * @param state state at switch time (with attitude computed using the {@code preceding} law)
  499.          * @exception OrekitException if some unexpected condition occurs
  500.          */
  501.         void switchOccurred(AttitudeProvider preceding, AttitudeProvider following, SpacecraftState state)
  502.             throws OrekitException;

  503.     }

  504. }