1   /* Copyright 2022-2025 Luc Maisonobe
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  
18  package org.orekit.forces.maneuvers.propulsion;
19  
20  import org.hipparchus.CalculusFieldElement;
21  import org.hipparchus.analysis.polynomials.PolynomialFunction;
22  import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
23  import org.hipparchus.geometry.euclidean.threed.Vector3D;
24  import org.orekit.time.AbsoluteDate;
25  import org.orekit.time.FieldAbsoluteDate;
26  
27  /** Thrust vector given as polynomials for the Cartesian coordinates.
28   * @author Luc Maisonobe
29   * @since 12.0
30   */
31  public class PolynomialThrustSegment implements ThrustVectorProvider {
32  
33      /** Reference date. */
34      private final AbsoluteDate referenceDate;
35  
36      /** Thrust along X direction (N). */
37      private final PolynomialFunction xThrust;
38  
39      /** Thrust along Y direction (N). */
40      private final PolynomialFunction yThrust;
41  
42      /** Thrust along Z direction (N). */
43      private final PolynomialFunction zThrust;
44  
45      /** Simple constructor.
46       * @param referenceDate reference date of the polynomials
47       * @param xThrust thrust along X direction (N)
48       * @param yThrust thrust along Y direction (N)
49       * @param zThrust thrust along Z direction (N)
50       */
51      public PolynomialThrustSegment(final AbsoluteDate referenceDate,
52                                     final PolynomialFunction xThrust,
53                                     final PolynomialFunction yThrust,
54                                     final PolynomialFunction zThrust) {
55          this.referenceDate = referenceDate;
56          this.xThrust       = xThrust;
57          this.yThrust       = yThrust;
58          this.zThrust       = zThrust;
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public Vector3D getThrustVector(final AbsoluteDate date, final double mass) {
64          final double dt = date.durationFrom(referenceDate);
65          return new Vector3D(xThrust.value(dt), yThrust.value(dt), zThrust.value(dt));
66      }
67  
68      /** {@inheritDoc} */
69      @Override
70      public <T extends CalculusFieldElement<T>> FieldVector3D<T> getThrustVector(final FieldAbsoluteDate<T> date,
71                                                                                  final T mass) {
72          final T dt = date.durationFrom(referenceDate);
73          return new FieldVector3D<>(xThrust.value(dt), yThrust.value(dt), zThrust.value(dt));
74      }
75  }