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  
19  import org.hipparchus.CalculusFieldElement;
20  import org.hipparchus.Field;
21  import org.hipparchus.geometry.euclidean.threed.FieldRotation;
22  import org.hipparchus.geometry.euclidean.threed.Rotation;
23  import org.orekit.frames.Frame;
24  import org.orekit.propagation.FieldSpacecraftState;
25  import org.orekit.propagation.SpacecraftState;
26  import org.orekit.propagation.events.EventDetector;
27  import org.orekit.propagation.events.EventDetectorsProvider;
28  import org.orekit.propagation.events.FieldEventDetector;
29  import org.orekit.time.AbsoluteDate;
30  import org.orekit.time.FieldAbsoluteDate;
31  import org.orekit.utils.FieldPVCoordinatesProvider;
32  import org.orekit.utils.PVCoordinatesProvider;
33  import org.orekit.utils.ParameterDriver;
34  
35  import java.util.ArrayList;
36  import java.util.List;
37  import java.util.stream.Stream;
38  
39  
40  /** This interface represents an attitude provider model set.
41   * <p>An attitude provider provides a way to compute an {@link Attitude Attitude}
42   * from an date and position-velocity local provider.</p>
43   * @author V&eacute;ronique Pommier-Maurussane
44   */
45  public interface AttitudeProvider extends EventDetectorsProvider, AttitudeRotationModel {
46  
47      /** Compute the attitude corresponding to an orbital state.
48       * @param pvProv local position-velocity provider around current date
49       * @param date current date
50       * @param frame reference frame from which attitude is computed
51       * @return attitude on the specified date and position-velocity state
52       */
53      Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame);
54  
55      /** Compute the attitude corresponding to an orbital state.
56       * @param pvProv local position-velocity provider around current date
57       * @param date current date
58       * @param frame reference frame from which attitude is computed
59       * @param <T> type of the field elements
60       * @return attitude on the specified date and position-velocity state
61       * @since 9.0
62       */
63      <T extends CalculusFieldElement<T>> FieldAttitude<T> getAttitude(FieldPVCoordinatesProvider<T> pvProv,
64                                                                       FieldAbsoluteDate<T> date,
65                                                                       Frame frame);
66  
67      /** Compute the attitude-related rotation corresponding to an orbital state.
68       * @param pvProv local position-velocity provider around current date
69       * @param date current date
70       * @param frame reference frame from which attitude is computed
71       * @return attitude-related rotation on the specified date and position-velocity state
72       * @since 12.0
73       */
74      default Rotation getAttitudeRotation(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) {
75          return getAttitude(pvProv, date, frame).getRotation();
76      }
77  
78      /** Compute the attitude-related rotation corresponding to an orbital state.
79       * @param pvProv local position-velocity provider around current date
80       * @param date current date
81       * @param frame reference frame from which attitude is computed
82       * @param <T> type of the field elements
83       * @return rotation on the specified date and position-velocity state
84       * @since 12.0
85       */
86      default <T extends CalculusFieldElement<T>> FieldRotation<T> getAttitudeRotation(final FieldPVCoordinatesProvider<T> pvProv,
87                                                                                       final FieldAbsoluteDate<T> date,
88                                                                                       final Frame frame) {
89          return getAttitude(pvProv, date, frame).getRotation();
90      }
91  
92      /** {@inheritDoc}
93       * The default implementation is independent of the input parameters as by default there is no driver.
94       * Users wanting to use them must override this.
95       * @since 13.0
96       */
97      @Override
98      default Rotation getAttitudeRotation(final SpacecraftState state, final double[] parameters) {
99          return getAttitudeRotation(state.isOrbitDefined() ? state.getOrbit() : state.getAbsPVA(), state.getDate(),
100                 state.getFrame());
101     }
102 
103     /** {@inheritDoc}
104      * The default implementation is independent of the input parameters as by default there is no driver.
105      * Users wanting to use them must override this.
106      * @since 13.0
107      */
108     @Override
109     default <T extends CalculusFieldElement<T>> FieldRotation<T> getAttitudeRotation(final FieldSpacecraftState<T> state,
110                                                                                      final T[] parameters) {
111         return getAttitudeRotation(state.isOrbitDefined() ? state.getOrbit() : state.getAbsPVA(), state.getDate(),
112                 state.getFrame());
113     }
114 
115     /** {@inheritDoc}
116      * @since 13.0
117      */
118     @Override
119     default Stream<EventDetector> getEventDetectors() {
120         return getEventDetectors(getParametersDrivers());
121     }
122 
123     /** {@inheritDoc}
124      * @since 13.0
125      */
126     @Override
127     default <T extends CalculusFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventDetectors(final Field<T> field) {
128         return getFieldEventDetectors(field, getParametersDrivers());
129     }
130 
131     /** {@inheritDoc}
132      * @since 13.0
133      */
134     @Override
135     default List<ParameterDriver> getParametersDrivers() {
136         return new ArrayList<>();
137     }
138 }