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.geometry.euclidean.threed.FieldRotation;
21 import org.hipparchus.geometry.euclidean.threed.Rotation;
22 import org.orekit.frames.Frame;
23 import org.orekit.time.AbsoluteDate;
24 import org.orekit.time.FieldAbsoluteDate;
25 import org.orekit.time.TimeInterval;
26 import org.orekit.utils.FieldPVCoordinatesProvider;
27 import org.orekit.utils.PVCoordinatesProvider;
28
29 /** This interface is intended for attitude ephemerides valid only during a time range.
30 *
31 * <p>This interface provides a mean to retrieve an attitude at
32 * any time within a given range. It should be implemented by attitude readers
33 * based on external data files.</p>
34 *
35 * @author Bryan Cazabonne
36 * @since 10.3
37 */
38 public interface BoundedAttitudeProvider extends AttitudeProvider {
39
40 /** Get the first date of the range.
41 * @return the first date of the range
42 */
43 AbsoluteDate getMinDate();
44
45 /** Get the last date of the range.
46 * @return the last date of the range
47 */
48 AbsoluteDate getMaxDate();
49
50 /**
51 * Creates a bounded provider given a time interval and a standard attitude provider, with the same outputs.
52 * @param attitudeProvider provider to be bounded
53 * @param interval time interval
54 * @return an instance of the interface
55 * @since 13.1
56 */
57 static BoundedAttitudeProvider of(final AttitudeProvider attitudeProvider, final TimeInterval interval) {
58 return new BoundedAttitudeProvider() {
59 @Override
60 public AbsoluteDate getMinDate() {
61 return interval.getStartDate();
62 }
63
64 @Override
65 public AbsoluteDate getMaxDate() {
66 return interval.getEndDate();
67 }
68
69 @Override
70 public Attitude getAttitude(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) {
71 return attitudeProvider.getAttitude(pvProv, date, frame);
72 }
73
74 @Override
75 public Rotation getAttitudeRotation(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) {
76 return attitudeProvider.getAttitudeRotation(pvProv, date, frame);
77 }
78
79 @Override
80 public <T extends CalculusFieldElement<T>> FieldAttitude<T> getAttitude(final FieldPVCoordinatesProvider<T> pvProv, final FieldAbsoluteDate<T> date, final Frame frame) {
81 return attitudeProvider.getAttitude(pvProv, date, frame);
82 }
83
84 @Override
85 public <T extends CalculusFieldElement<T>> FieldRotation<T> getAttitudeRotation(final FieldPVCoordinatesProvider<T> pvProv, final FieldAbsoluteDate<T> date, final Frame frame) {
86 return attitudeProvider.getAttitudeRotation(pvProv, date, frame);
87 }
88 };
89 }
90 }