AttitudeProvider.java

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

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;
  20. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  21. import org.hipparchus.geometry.euclidean.threed.Rotation;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.propagation.FieldSpacecraftState;
  24. import org.orekit.propagation.SpacecraftState;
  25. import org.orekit.propagation.events.EventDetector;
  26. import org.orekit.propagation.events.EventDetectorsProvider;
  27. import org.orekit.propagation.events.FieldEventDetector;
  28. import org.orekit.time.AbsoluteDate;
  29. import org.orekit.time.FieldAbsoluteDate;
  30. import org.orekit.utils.FieldPVCoordinatesProvider;
  31. import org.orekit.utils.PVCoordinatesProvider;
  32. import org.orekit.utils.ParameterDriver;

  33. import java.util.ArrayList;
  34. import java.util.List;
  35. import java.util.stream.Stream;


  36. /** This interface represents an attitude provider model set.
  37.  * <p>An attitude provider provides a way to compute an {@link Attitude Attitude}
  38.  * from an date and position-velocity local provider.</p>
  39.  * @author V&eacute;ronique Pommier-Maurussane
  40.  */
  41. public interface AttitudeProvider extends EventDetectorsProvider, AttitudeRotationModel {

  42.     /** Compute the attitude corresponding to an orbital state.
  43.      * @param pvProv local position-velocity provider around current date
  44.      * @param date current date
  45.      * @param frame reference frame from which attitude is computed
  46.      * @return attitude on the specified date and position-velocity state
  47.      */
  48.     Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame);

  49.     /** Compute the attitude corresponding to an orbital state.
  50.      * @param pvProv local position-velocity provider around current date
  51.      * @param date current date
  52.      * @param frame reference frame from which attitude is computed
  53.      * @param <T> type of the field elements
  54.      * @return attitude on the specified date and position-velocity state
  55.      * @since 9.0
  56.      */
  57.     <T extends CalculusFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv,
  58.                                                                      FieldAbsoluteDate<T> date,
  59.                                                                      Frame frame);

  60.     /** Compute the attitude-related rotation corresponding to an orbital state.
  61.      * @param pvProv local position-velocity provider around current date
  62.      * @param date current date
  63.      * @param frame reference frame from which attitude is computed
  64.      * @return attitude-related rotation on the specified date and position-velocity state
  65.      * @since 12.0
  66.      */
  67.     default Rotation getAttitudeRotation(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) {
  68.         return getAttitude(pvProv, date, frame).getRotation();
  69.     }

  70.     /** Compute the attitude-related rotation corresponding to an orbital state.
  71.      * @param pvProv local position-velocity provider around current date
  72.      * @param date current date
  73.      * @param frame reference frame from which attitude is computed
  74.      * @param <T> type of the field elements
  75.      * @return rotation on the specified date and position-velocity state
  76.      * @since 12.0
  77.      */
  78.     default <T extends CalculusFieldElement<T>> FieldRotation<T> getAttitudeRotation(FieldPVCoordinatesProvider<T> pvProv,
  79.                                                                                      FieldAbsoluteDate<T> date,
  80.                                                                                      Frame frame) {
  81.         return getAttitude(pvProv, date, frame).getRotation();
  82.     }

  83.     /** {@inheritDoc}
  84.      * The default implementation is independent of the input parameters as by default there is no driver.
  85.      * Users wanting to use them must override this.
  86.      * @since 13.0
  87.      */
  88.     @Override
  89.     default Rotation getAttitudeRotation(final SpacecraftState state, final double[] parameters) {
  90.         return getAttitudeRotation(state.isOrbitDefined() ? state.getOrbit() : state.getAbsPVA(), state.getDate(),
  91.                 state.getFrame());
  92.     }

  93.     /** {@inheritDoc}
  94.      * The default implementation is independent of the input parameters as by default there is no driver.
  95.      * Users wanting to use them must override this.
  96.      * @since 13.0
  97.      */
  98.     @Override
  99.     default <T extends CalculusFieldElement<T>> FieldRotation<T> getAttitudeRotation(final FieldSpacecraftState<T> state,
  100.                                                                                      final T[] parameters) {
  101.         return getAttitudeRotation(state.isOrbitDefined() ? state.getOrbit() : state.getAbsPVA(), state.getDate(),
  102.                 state.getFrame());
  103.     }

  104.     /** {@inheritDoc}
  105.      * @since 13.0
  106.      */
  107.     @Override
  108.     default Stream<EventDetector> getEventDetectors() {
  109.         return getEventDetectors(getParametersDrivers());
  110.     }

  111.     /** {@inheritDoc}
  112.      * @since 13.0
  113.      */
  114.     @Override
  115.     default <T extends CalculusFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventDetectors(final Field<T> field) {
  116.         return getFieldEventDetectors(field, getParametersDrivers());
  117.     }

  118.     /** {@inheritDoc}
  119.      * @since 13.0
  120.      */
  121.     @Override
  122.     default List<ParameterDriver> getParametersDrivers() {
  123.         return new ArrayList<>();
  124.     }
  125. }