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.attitudes;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
21 import org.hipparchus.geometry.euclidean.threed.Vector3D;
22 import org.orekit.frames.Frame;
23 import org.orekit.time.AbsoluteDate;
24 import org.orekit.time.FieldAbsoluteDate;
25 import org.orekit.utils.FieldPVCoordinatesProvider;
26 import org.orekit.utils.PVCoordinatesProvider;
27 import org.orekit.utils.TimeStampedFieldPVCoordinates;
28 import org.orekit.utils.TimeStampedPVCoordinates;
29
30 /**
31 * Abstract class for attitude provider modifiers using an underlying ground pointing law.
32 *
33 * @see GroundPointing
34 * @see AttitudeProviderModifier
35 * @author Romain Serra
36 * @since 12.1
37 */
38 public abstract class GroundPointingAttitudeModifier extends GroundPointing implements AttitudeProviderModifier {
39
40 /**
41 * Underlying ground pointing law.
42 */
43 private final GroundPointing groundPointingLaw;
44
45 /** Constructor.
46 * @param inertialFrame frame in which orbital velocities are computed
47 * @param bodyFrame the frame that rotates with the body
48 * @param groundPointingLaw underlying ground pointing attitude law
49 */
50 protected GroundPointingAttitudeModifier(final Frame inertialFrame, final Frame bodyFrame,
51 final GroundPointing groundPointingLaw) {
52 super(inertialFrame, bodyFrame);
53 this.groundPointingLaw = groundPointingLaw;
54 }
55
56 /**
57 * Getter for underlying ground pointing law.
58 * @return underlying attitude provider, which in this case is a {@link GroundPointing} instance
59 */
60 @Override
61 public GroundPointing getUnderlyingAttitudeProvider() {
62 return groundPointingLaw;
63 }
64
65 /** Compute the base system state at given date, without modifications.
66 * @param pvProv provider for PV coordinates
67 * @param date date at which state is requested
68 * @param frame reference frame from which attitude is computed
69 * @return satellite base attitude state.
70 */
71 public Attitude getBaseState(final PVCoordinatesProvider pvProv,
72 final AbsoluteDate date, final Frame frame) {
73 return getUnderlyingAttitudeProvider().getAttitude(pvProv, date, frame);
74 }
75
76 /** Compute the base system state at given date, without modifications.
77 * @param pvProv provider for PV coordinates
78 * @param date date at which state is requested
79 * @param frame reference frame from which attitude is computed
80 * @param <T> type of the field elements
81 * @return satellite base attitude state.
82 */
83 public <T extends CalculusFieldElement<T>> FieldAttitude<T> getBaseState(final FieldPVCoordinatesProvider<T> pvProv,
84 final FieldAbsoluteDate<T> date, final Frame frame) {
85 return getUnderlyingAttitudeProvider().getAttitude(pvProv, date, frame);
86 }
87
88 /** {@inheritDoc} */
89 @Override
90 public TimeStampedPVCoordinates getTargetPV(final PVCoordinatesProvider pvProv,
91 final AbsoluteDate date, final Frame frame) {
92 return groundPointingLaw.getTargetPV(pvProv, date, frame);
93 }
94
95 /** {@inheritDoc} */
96 @Override
97 protected Vector3D getTargetPosition(final PVCoordinatesProvider pvProv, final AbsoluteDate date, final Frame frame) {
98 return groundPointingLaw.getTargetPosition(pvProv, date, frame);
99 }
100
101 /** {@inheritDoc} */
102 @Override
103 public <T extends CalculusFieldElement<T>> TimeStampedFieldPVCoordinates<T> getTargetPV(final FieldPVCoordinatesProvider<T> pvProv,
104 final FieldAbsoluteDate<T> date,
105 final Frame frame) {
106 return groundPointingLaw.getTargetPV(pvProv, date, frame);
107 }
108
109 /** {@inheritDoc} */
110 @Override
111 protected <T extends CalculusFieldElement<T>> FieldVector3D<T> getTargetPosition(final FieldPVCoordinatesProvider<T> pvProv,
112 final FieldAbsoluteDate<T> date,
113 final Frame frame) {
114 return groundPointingLaw.getTargetPosition(pvProv, date, frame);
115 }
116 }