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.propagation.conversion;
18  
19  import org.orekit.attitudes.AttitudeProvider;
20  import org.orekit.attitudes.FrameAlignedProvider;
21  import org.orekit.orbits.Orbit;
22  import org.orekit.orbits.PositionAngleType;
23  import org.orekit.propagation.Propagator;
24  import org.orekit.propagation.analytical.KeplerianPropagator;
25  
26  
27  /** Builder for Keplerian propagator.
28   * @author Pascal Parraud
29   * @since 6.0
30   */
31  public class KeplerianPropagatorBuilder extends AbstractAnalyticalPropagatorBuilder<KeplerianPropagator> {
32  
33      /** Build a new instance.
34       * <p>
35       * The template orbit is used as a model to {@link
36       * #createInitialOrbit() create initial orbit}. It defines the
37       * inertial frame, the central attraction coefficient, the orbit type, and is also
38       * used together with the {@code positionScale} to convert from the {@link
39       * org.orekit.utils.ParameterDriver#setNormalizedValue(double) normalized} parameters used by the
40       * callers of this builder to the real orbital parameters.
41       * The default attitude provider is aligned with the orbit's inertial frame.
42       * </p>
43       *
44       * @param templateOrbit reference orbit from which real orbits will be built
45       * @param positionAngleType position angle type to use
46       * @param positionScale scaling factor used for orbital parameters normalization
47       * (typically set to the expected standard deviation of the position)
48       * @since 8.0
49       * @see #KeplerianPropagatorBuilder(Orbit, PositionAngleType, double, AttitudeProvider)
50       */
51      public KeplerianPropagatorBuilder(final Orbit templateOrbit, final PositionAngleType positionAngleType,
52                                        final double positionScale) {
53          this(templateOrbit, positionAngleType, positionScale,
54               FrameAlignedProvider.of(templateOrbit.getFrame()));
55      }
56  
57      /** Build a new instance.
58       * <p>
59       * The template orbit is used as a model to {@link
60       * #createInitialOrbit() create initial orbit}. It defines the
61       * inertial frame, the central attraction coefficient, the orbit type, and is also
62       * used together with the {@code positionScale} to convert from the {@link
63       * org.orekit.utils.ParameterDriver#setNormalizedValue(double) normalized} parameters used by the
64       * callers of this builder to the real orbital parameters.
65       * </p>
66       * @param templateOrbit reference orbit from which real orbits will be built
67       * @param positionAngleType position angle type to use
68       * @param positionScale scaling factor used for orbital parameters normalization
69       * (typically set to the expected standard deviation of the position)
70       * @param attitudeProvider attitude law to use.
71       * @since 10.1
72       */
73      public KeplerianPropagatorBuilder(final Orbit templateOrbit,
74                                        final PositionAngleType positionAngleType,
75                                        final double positionScale,
76                                        final AttitudeProvider attitudeProvider) {
77          super(templateOrbit, positionAngleType, positionScale, true, attitudeProvider, Propagator.DEFAULT_MASS);
78      }
79  
80      /** {@inheritDoc} */
81      public KeplerianPropagator buildPropagator(final double[] normalizedParameters) {
82          setParameters(normalizedParameters);
83          final KeplerianPropagator propagator = new KeplerianPropagator(createInitialOrbit(), getAttitudeProvider(), getMu(), getMass());
84          getImpulseManeuvers().forEach(propagator::addEventDetector);
85          return propagator;
86      }
87  }