FieldImpulseProvider.java

  1. /* Copyright 2022-2025 Romain Serra
  2.  * Licensed to CS GROUP (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.forces.maneuvers;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  22. import org.orekit.propagation.FieldSpacecraftState;
  23. import org.orekit.time.FieldAbsoluteDate;

  24. /** Interface providing velocity increment vectors to impulsive maneuvers (Field version).
  25.  *
  26.  * @author Romain Serra
  27.  * @see ImpulseProvider
  28.  * @see FieldImpulseManeuver
  29.  * @since 13.0
  30.  */
  31. public interface FieldImpulseProvider<T extends CalculusFieldElement<T>> {

  32.     /**
  33.      * Method returning the impulse to be applied (Field version).
  34.      * @param state state before the maneuver is applied if {@code isForward} is true, after otherwise
  35.      * @param isForward flag on propagation direction
  36.      * @return impulse in satellite's frame
  37.      */
  38.     FieldVector3D<T> getImpulse(FieldSpacecraftState<T> state, boolean isForward);

  39.     /**
  40.      * Method called at start of propagation.
  41.      * @param initialState state at start of propagation
  42.      * @param targetDate target end date
  43.      */
  44.     default void init(FieldSpacecraftState<T> initialState, FieldAbsoluteDate<T> targetDate) {
  45.         // nothing by default
  46.     }

  47.     /**
  48.      * Method called at end of propagation.
  49.      * @param finalState state at end of propagation
  50.      */
  51.     default void finish(FieldSpacecraftState<T> finalState) {
  52.         // nothing by default
  53.     }

  54.     /**
  55.      * Get a provider returning a given vector for forward propagation and its opposite for backward.
  56.      * @param forwardImpulse forward impulse vector
  57.      * @param <T> field type
  58.      * @return constant provider
  59.      */
  60.     static <T extends CalculusFieldElement<T>> FieldImpulseProvider<T> of(final FieldVector3D<T> forwardImpulse) {
  61.         return (state, isForward) -> isForward ? forwardImpulse : forwardImpulse.negate();
  62.     }

  63.     /**
  64.      * Get a provider returning a given vector for forward propagation and its opposite for backward.
  65.      * @param forwardImpulse forward impulse vector
  66.      * @param field field
  67.      * @param <T> field type
  68.      * @return constant provider
  69.      */
  70.     static <T extends CalculusFieldElement<T>> FieldImpulseProvider<T> of(final Field<T> field,
  71.                                                                           final Vector3D forwardImpulse) {
  72.         return of(new FieldVector3D<>(field, forwardImpulse));
  73.     }

  74.     /**
  75.      * Get a provider from a non-Field version.
  76.      * @param impulseProvider impulse provider
  77.      * @param <T> field type
  78.      * @return provider
  79.      */
  80.     static <T extends CalculusFieldElement<T>> FieldImpulseProvider<T> of(final ImpulseProvider impulseProvider) {
  81.         return (state, isForward) -> {
  82.             final Vector3D deltaV = impulseProvider.getImpulse(state.toSpacecraftState(), isForward);
  83.             return new FieldVector3D<>(state.getDate().getField(), deltaV);
  84.         };
  85.     }
  86. }