1 /* Copyright 2002-2026 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.propagation.relative;
18
19 import org.orekit.frames.Frame;
20 import org.orekit.frames.LOF;
21 import org.orekit.frames.Transform;
22 import org.orekit.orbits.Orbit;
23 import org.orekit.utils.TimeStampedPVCoordinates;
24
25 /**
26 * Abstraction class for RelativeProvider.
27 *
28 * @author Romain Cuvillon
29 * @since 14.0
30 */
31 public abstract class AbstractRelativeProvider implements RelativeProvider {
32
33 /**
34 * Additional equations name.
35 */
36 private final String additionalEquationsName;
37
38 /**
39 * Initial chaser PVT in the target's LOF.
40 */
41 private TimeStampedPVCoordinates initialChaserPVTLof;
42
43 /**
44 * Target's orbit.
45 */
46 private Orbit targetOrbit;
47
48 /**
49 * Local Orbital Frame.
50 */
51 private final LOF lof;
52
53 /**
54 * Builds a new RelativeProvider object from the target orbit and an initial PVT of the chaser.
55 *
56 * @param targetOrbit Target orbit
57 * @param initialChaserPVTLof Chaser PVT in the target's local orbital frame
58 * @param additionalEquationsName Additional equations name
59 * @param lof Local Orbital Frame
60 */
61 public AbstractRelativeProvider(final Orbit targetOrbit,
62 final TimeStampedPVCoordinates initialChaserPVTLof,
63 final String additionalEquationsName,
64 final LOF lof) {
65 this.targetOrbit = targetOrbit;
66 this.initialChaserPVTLof = initialChaserPVTLof;
67 this.additionalEquationsName = additionalEquationsName;
68 this.lof = lof;
69 }
70
71 /**
72 * Builds a new RelativeProvider object from the target orbit and additionalEquationsName.
73 *
74 * @param targetOrbit Target orbit
75 * @param additionalEquationsName Additional equations name
76 * @param lof Local Orbital Frame
77 */
78 public AbstractRelativeProvider(final Orbit targetOrbit, final String additionalEquationsName, final LOF lof) {
79 // Copy input parameters
80 this.targetOrbit = targetOrbit;
81 this.additionalEquationsName = additionalEquationsName;
82 this.lof = lof;
83 }
84
85 /**
86 * Builds a new RelativeProvider object from the target orbit and an initial PVT of the chaser expressed in
87 * the given input frame.
88 *
89 * @param targetOrbit Target orbit
90 * @param initialChaserPVT Chaser PVT in the input Frame
91 * @param inputPVTFrame Input frame for the initial chaser PVT
92 * @param additionalEquationsName Additional equations name
93 * @param lof Local Orbital Frame
94 */
95 public AbstractRelativeProvider(final Orbit targetOrbit,
96 final TimeStampedPVCoordinates initialChaserPVT,
97 final Frame inputPVTFrame,
98 final String additionalEquationsName,
99 final LOF lof) {
100 // Copy input parameters
101 this.targetOrbit = targetOrbit;
102 this.additionalEquationsName = additionalEquationsName;
103 this.lof = lof;
104
105 // Transform PV from input frame to inertial frame of target Orbit.
106 final Transform inputFrameToInertial = inputPVTFrame.getTransformTo(targetOrbit.getFrame(),
107 targetOrbit.getDate());
108 final TimeStampedPVCoordinates pvInertial = inputFrameToInertial.transformPVCoordinates(initialChaserPVT);
109
110 // Transform and set PV from inertial to target's LOF.
111 setInitialChaserPVTLof(getLof().transformFromInertial(targetOrbit.getDate(), targetOrbit.getPVCoordinates())
112 .transformPVCoordinates(pvInertial));
113 }
114
115 /** {@inheritDoc}. */
116 @Override
117 public LOF getLof() {
118 return lof;
119 }
120
121 /** {@inheritDoc}. */
122 @Override
123 public void setInitialChaserPVTLof(final TimeStampedPVCoordinates initialChaserPVTLof) {
124 this.initialChaserPVTLof = initialChaserPVTLof;
125 }
126
127 @Override
128 public TimeStampedPVCoordinates getInitialChaserPVTLof() {
129 return initialChaserPVTLof;
130 }
131
132 @Override
133 public String getName() {
134 return additionalEquationsName;
135 }
136
137 /** {@inheritDoc}. */
138 @Override
139 public Orbit getTargetOrbit() {
140 return targetOrbit;
141 }
142
143 /** {@inheritDoc}. */
144 @Override
145 public void setTargetOrbit(final Orbit targetOrbit) {
146 this.targetOrbit = targetOrbit;
147 }
148 }