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.bodies;
18  
19  import org.orekit.annotation.DefaultDataContext;
20  import org.orekit.propagation.numerical.cr3bp.CR3BPConstants;
21  import org.orekit.time.AbsoluteDate;
22  import org.orekit.time.TimeScale;
23  
24  /**
25   * Factory class creating predefined CR3BP system using CR3BPSystem class. For example, Earth-Moon CR3BP
26   * System.
27   * @author Vincent Mouraux
28   * @see CR3BPSystem
29   * @since 10.2
30   */
31  public class CR3BPFactory {
32  
33      /** Private constructor.
34       * <p>This class is a utility class, it should neither have a public
35       * nor a default constructor. This private constructor prevents
36       * the compiler from generating one automatically.</p>
37       */
38      private CR3BPFactory() {
39      }
40  
41      /** Get the Sun-Jupiter CR3BP singleton bodies pair.
42       * @param date date
43       * @param timeScale time scale
44       * @return Sun-Jupiter CR3BP system
45       */
46      @DefaultDataContext
47      public static CR3BPSystem getSunJupiterCR3BP(final AbsoluteDate date, final TimeScale timeScale) {
48          return getSystem(CelestialBodyFactory.getSun(), CelestialBodyFactory.getJupiter(), CR3BPConstants.getJupiterSemiMajorAxis(date, timeScale));
49      }
50  
51      /** Get the Sun-Earth CR3BP singleton bodies pair.
52       * @param date date
53       * @param timeScale time scale
54       * @return Sun-Earth CR3BP system
55       */
56      @DefaultDataContext
57      public static CR3BPSystem getSunEarthCR3BP(final AbsoluteDate date, final TimeScale timeScale) {
58          return getSystem(CelestialBodyFactory.getSun(), CelestialBodyFactory.getEarthMoonBarycenter(), CR3BPConstants.getEarthMoonBarycenterSemiMajorAxis(date, timeScale));
59      }
60  
61      /** Get the Earth-Moon CR3BP singleton bodies pair.
62       * @return Earth-Moon CR3BP system
63       */
64      @DefaultDataContext
65      public static CR3BPSystem getEarthMoonCR3BP() {
66          return getSystem(CelestialBodyFactory.getEarth(), CelestialBodyFactory.getMoon(), CR3BPConstants.getMoonSemiMajorAxis());
67      }
68  
69      /** Get the corresponding CR3BP System.
70       * @param primaryBody Primary Body in the CR3BP System
71       * @param secondaryBody Secondary Body in the CR3BP System
72       * @param a Semi-Major Axis of the secondary body
73       * @return corresponding CR3BP System
74       */
75      public static CR3BPSystem getSystem(final CelestialBody primaryBody, final CelestialBody secondaryBody, final double a) {
76          return new CR3BPSystem(primaryBody, secondaryBody, a);
77      }
78  }