+
+
+
+ org.orekit.propagation.events.*
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 74ced757e..96e3fcc58 100644
--- a/pom.xml
+++ b/pom.xml
@@ -406,6 +406,18 @@
testfalse
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.8.1
+ test
+
+
+ org.assertj
+ assertj-core
+ 3.23.1
+ test
+
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
new file mode 100644
index 000000000..a61ae26b0
--- /dev/null
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -0,0 +1,85 @@
+package org.orekit.propagation.events;
+
+import org.hipparchus.geometry.euclidean.threed.Vector3D;
+import org.hipparchus.ode.events.Action;
+import org.orekit.propagation.SpacecraftState;
+import org.orekit.propagation.events.handlers.EventHandler;
+import org.orekit.propagation.events.handlers.StopOnIncreasing;
+import org.orekit.utils.PVCoordinates;
+import org.orekit.utils.PVCoordinatesProvider;
+
+/**
+ * Finder for extremum approach events.
+ *
This class finds extremum approach events (i.e. closest or farthest approach).
+ *
The default implementation behavior is to {@link Action#CONTINUE continue}
+ * propagation at farthest approach and to {@link Action#STOP stop} propagation at closest approach. This can be changed
+ * by calling {@link #withHandler(EventHandler)} after construction.
+ *
It is also possible to detect solely one type of event using an {@link EventSlopeFilter event slope filter}. For
+ * example in order to only detect closest approach, one should type the following :
+ *
{@code
+ * ExtremumApproachDetector rawDetector = new ExtremumApproachDetector(otherPVProvider);
+ * EventDetector closeApproachDetector = new EventSlopeFilter(rawDetector,FilterType.TRIGGER_ONLY_INCREASING_EVENTS);
+ * }
+ *
+ *
+ * @author Vincent Cucchietti
+ * @see org.orekit.propagation.Propagator#addEventDetector(EventDetector)
+ * @see EventSlopeFilter
+ * @see FilterType
+ */
+public class ExtremumApproachDetector extends AbstractDetector {
+
+ /**
+ * PVCoordinates provider of the other object with which we want to find out the extremum approach.
+ */
+ private final PVCoordinatesProvider otherPVProvider;
+
+ /**
+ * Constructor with default values.
+ *
+ * @param otherPVProvider PVCoordinates provider of the other object with which we want to find out the extremum
+ * approach.
+ */
+ public ExtremumApproachDetector(final PVCoordinatesProvider otherPVProvider) {
+ this(DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER, new StopOnIncreasing<>(), otherPVProvider);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param maxCheck maximum checking interval (s)
+ * @param threshold convergence threshold (s)
+ * @param maxIter maximum number of iterations in the event time search
+ * @param handler event handler to call at event occurrences
+ * @param otherPVProvider PVCoordinates provider of the other object with which we want to find out the extremum *
+ * approach.
+ */
+ public ExtremumApproachDetector(
+ final double maxCheck, final double threshold, final int maxIter,
+ final EventHandler super ExtremumApproachDetector> handler, final PVCoordinatesProvider otherPVProvider) {
+ super(maxCheck, threshold, maxIter, handler);
+ this.otherPVProvider = otherPVProvider;
+ }
+
+ /** {@inheritDoc} */
+ public double g(final SpacecraftState s) {
+ final PVCoordinates deltaPV = deltaPV(s);
+ return Vector3D.dotProduct(deltaPV.getPosition().normalize(), deltaPV.getVelocity());
+ }
+
+ /**
+ * @param s Spacecraft state.
+ * @return Relative position between s and otherPVProvider.
+ */
+ protected PVCoordinates deltaPV(final SpacecraftState s) {
+ return new PVCoordinates(s.getPVCoordinates(),
+ otherPVProvider.getPVCoordinates(s.getDate(), s.getFrame()));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected ExtremumApproachDetector create(final double newMaxCheck, final double newThreshold, final int newMaxIter,
+ final EventHandler super ExtremumApproachDetector> newHandler) {
+ return new ExtremumApproachDetector(newMaxCheck, newThreshold, newMaxIter, newHandler, otherPVProvider);
+ }
+}
diff --git a/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java b/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
new file mode 100644
index 000000000..ab02cb370
--- /dev/null
+++ b/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
@@ -0,0 +1,103 @@
+package org.orekit.propagation.events;
+
+import org.assertj.core.api.Assertions;
+import org.hipparchus.util.FastMath;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.orekit.Utils;
+import org.orekit.bodies.CelestialBodyFactory;
+import org.orekit.frames.Frame;
+import org.orekit.frames.FramesFactory;
+import org.orekit.orbits.KeplerianOrbit;
+import org.orekit.orbits.Orbit;
+import org.orekit.orbits.PositionAngle;
+import org.orekit.propagation.Propagator;
+import org.orekit.propagation.SpacecraftState;
+import org.orekit.propagation.analytical.KeplerianPropagator;
+import org.orekit.propagation.events.handlers.StopOnEvent;
+import org.orekit.time.AbsoluteDate;
+import org.orekit.utils.PVCoordinatesProvider;
+
+import static org.assertj.core.api.Assertions.withPrecision;
+
+public class ExtremumApproachDetectorTest {
+
+ @Test
+ @DisplayName("Test the detector on a keplerian orbit and detect extremum approach with Earth.")
+ void Should_stop_propagation_at_closest_approach_by_default() {
+ // Given
+ Utils.setDataRoot("regular-data");
+
+ final AbsoluteDate initialDate = new AbsoluteDate();
+ final Frame frame = FramesFactory.getEME2000();
+ final double mu = 398600e9; //m**3/s**2
+
+ final double rp = (6378 + 400) * 1000; //m
+ final double ra = (6378 + 800) * 1000; //m
+
+ final double a = (ra + rp) / 2; //m
+ final double e = (ra - rp) / (ra + rp); //m
+ final double i = 0; //rad
+ final double pa = 0; //rad
+ final double raan = 0; //rad
+ final double anomaly = FastMath.toRadians(0); //rad
+ final Orbit orbit =
+ new KeplerianOrbit(a, e, i, pa, raan, anomaly, PositionAngle.TRUE, frame, initialDate, mu);
+
+ final PVCoordinatesProvider earthPVProvider = CelestialBodyFactory.getEarth();
+
+ final ExtremumApproachDetector detector = new ExtremumApproachDetector(earthPVProvider);
+
+ final Propagator propagator = new KeplerianPropagator(orbit);
+ propagator.addEventDetector(detector);
+
+ // When
+ final SpacecraftState stateAtEvent =
+ propagator.propagate(initialDate.shiftedBy(orbit.getKeplerianPeriod() * 2));
+
+ // Then
+ Assertions.assertThat(stateAtEvent.getDate().durationFrom(initialDate))
+ .isEqualTo(orbit.getKeplerianPeriod(), withPrecision(2.0e-12));
+
+ }
+
+ @Test
+ @DisplayName("Test the detector on a keplerian orbit and detect extremum approach with Earth.")
+ void Should_stop_propagation_at_farthest_approach_with_handler() {
+ // Given
+ Utils.setDataRoot("regular-data");
+
+ final AbsoluteDate initialDate = new AbsoluteDate();
+ final Frame frame = FramesFactory.getEME2000();
+ final double mu = 398600e9; //m**3/s**2
+
+ final double rp = (6378 + 400) * 1000; //m
+ final double ra = (6378 + 800) * 1000; //m
+
+ final double a = (ra + rp) / 2; //m
+ final double e = (ra - rp) / (ra + rp); //m
+ final double i = 0; //rad
+ final double pa = 0; //rad
+ final double raan = 0; //rad
+ final double anomaly = FastMath.toRadians(0); //rad
+ final Orbit orbit =
+ new KeplerianOrbit(a, e, i, pa, raan, anomaly, PositionAngle.TRUE, frame, initialDate, mu);
+
+ final PVCoordinatesProvider earthPVProvider = CelestialBodyFactory.getEarth();
+
+ final ExtremumApproachDetector detector =
+ new ExtremumApproachDetector(earthPVProvider).withHandler(new StopOnEvent<>());
+
+ final Propagator propagator = new KeplerianPropagator(orbit);
+ propagator.addEventDetector(detector);
+
+ // When
+ final SpacecraftState stateAtEvent =
+ propagator.propagate(initialDate.shiftedBy(orbit.getKeplerianPeriod() * 2));
+
+ // Then
+ Assertions.assertThat(stateAtEvent.getDate().durationFrom(initialDate))
+ .isEqualTo(orbit.getKeplerianPeriod() / 2, withPrecision(1.27798E-8));
+
+ }
+}
\ No newline at end of file
--
GitLab
From 10873c0d8321ce84b5cf88981ed0f5621844f70b Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Wed, 17 Aug 2022 14:28:05 +0200
Subject: [PATCH 03/29] Documentation
docs: Fixed documentation and added license header for ExtremumApproachDetector and its test class.
---
.idea/compiler.xml | 1 -
.idea/workspace.xml | 23 +++++++-------
.../events/ExtremumApproachDetector.java | 26 ++++++++++++----
.../events/ExtremumApproachDetectorTest.java | 30 ++++++++++++++-----
4 files changed, 57 insertions(+), 23 deletions(-)
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 28c706f7a..cd8416f7f 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,7 +1,6 @@
-
- {
+ "keyToString": {
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "last_opened_file_path": "/home/vcucchie/git/Backup forks/orekit",
+ "settings.editor.selected.configurable": "reference.projectsettings.compiler.javacompiler"
}
-}]]>
+}
@@ -185,5 +184,9 @@
org.orekit.propagation.events.*
+
+
+ org.orekit.frames.*
+
\ No newline at end of file
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index a61ae26b0..dc02fec0d 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.orekit.propagation.events;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
@@ -17,8 +33,8 @@ import org.orekit.utils.PVCoordinatesProvider;
*
It is also possible to detect solely one type of event using an {@link EventSlopeFilter event slope filter}. For
* example in order to only detect closest approach, one should type the following :
*
{@code
- * ExtremumApproachDetector rawDetector = new ExtremumApproachDetector(otherPVProvider);
- * EventDetector closeApproachDetector = new EventSlopeFilter(rawDetector,FilterType.TRIGGER_ONLY_INCREASING_EVENTS);
+ * ExtremumApproachDetector extremumApproachDetector = new ExtremumApproachDetector(otherPVProvider);
+ * EventDetector closeApproachDetector = new EventSlopeFilter(extremumApproachDetector,FilterType.TRIGGER_ONLY_INCREASING_EVENTS);
* }
*
*
@@ -55,8 +71,8 @@ public class ExtremumApproachDetector extends AbstractDetector handler, final PVCoordinatesProvider otherPVProvider) {
+ final double maxCheck, final double threshold, final int maxIter,
+ final EventHandler super ExtremumApproachDetector> handler, final PVCoordinatesProvider otherPVProvider) {
super(maxCheck, threshold, maxIter, handler);
this.otherPVProvider = otherPVProvider;
}
@@ -73,7 +89,7 @@ public class ExtremumApproachDetector extends AbstractDetector());
+ new ExtremumApproachDetector(earthPVProvider).withHandler(new StopOnEvent<>());
final Propagator propagator = new KeplerianPropagator(orbit);
propagator.addEventDetector(detector);
// When
final SpacecraftState stateAtEvent =
- propagator.propagate(initialDate.shiftedBy(orbit.getKeplerianPeriod() * 2));
+ propagator.propagate(initialDate.shiftedBy(orbit.getKeplerianPeriod() * 2));
// Then
Assertions.assertThat(stateAtEvent.getDate().durationFrom(initialDate))
- .isEqualTo(orbit.getKeplerianPeriod() / 2, withPrecision(1.27798E-8));
+ .isEqualTo(orbit.getKeplerianPeriod() / 2, withPrecision(1.27798E-8));
}
}
\ No newline at end of file
--
GitLab
From a4c20b5c3878d3c95b84bc266681900cdc68ceee Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Wed, 17 Aug 2022 14:37:23 +0200
Subject: [PATCH 04/29] Changed branch name to issue-952.
---
.idea/workspace.xml | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7a24a8b30..7196e2895 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,12 +4,7 @@
-
-
-
-
-
-
+
@@ -162,7 +157,14 @@
1660723232697
-
+
+ 1660739285246
+
+
+
+ 1660739285246
+
+
@@ -178,7 +180,8 @@
-
+
+
--
GitLab
From 7bb49f53029ff43adda4657f5c881b08b1de8323 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Wed, 17 Aug 2022 14:43:22 +0200
Subject: [PATCH 05/29] Changed branch name to issue-952.
---
.idea/workspace.xml | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7196e2895..56cdffe32 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,7 @@
-
-
-
- org.orekit.propagation.events.*
-
-
-
- org.orekit.frames.*
-
-
-
\ No newline at end of file
--
GitLab
From f6818206161b7e98707b934aecee6001a5de11c4 Mon Sep 17 00:00:00 2001
From: Vincent CUCCHIETTI
Date: Wed, 17 Aug 2022 13:36:17 +0000
Subject: [PATCH 14/29] Delete orekit.iml
---
orekit.iml | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 orekit.iml
diff --git a/orekit.iml b/orekit.iml
deleted file mode 100644
index c3e1ecfed..000000000
--- a/orekit.iml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
--
GitLab
From 230d02aab4d0b519b5965d97e5466ab9f0698d2a Mon Sep 17 00:00:00 2001
From: Vincent CUCCHIETTI
Date: Wed, 17 Aug 2022 13:39:34 +0000
Subject: [PATCH 15/29] Update
src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
---
.../propagation/events/ExtremumApproachDetector.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index dc02fec0d..a4ddabdb0 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -63,10 +63,10 @@ public class ExtremumApproachDetector extends AbstractDetector
Date: Wed, 17 Aug 2022 13:45:34 +0000
Subject: [PATCH 16/29] Update src/changes/changes.xml
---
src/changes/changes.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6a3270556..658b5cd94 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -27,7 +27,7 @@
Added waypoint interpolation of PVCoordinatesProvider.
-
+
Added ExtremumApproachDetector.
--
GitLab
From 0f305847f3394fdf6d64124152b62b87df36f9d2 Mon Sep 17 00:00:00 2001
From: Vincent CUCCHIETTI
Date: Wed, 17 Aug 2022 15:31:55 +0000
Subject: [PATCH 17/29] Update
src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
---
.../propagation/events/ExtremumApproachDetector.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index a4ddabdb0..18eb0acf5 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -1,12 +1,12 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
+/* Copyright 2002-2022 CS GROUP
+ * Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
+ * CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.orekit.propagation.events;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
@@ -80,7 +81,7 @@ public class ExtremumApproachDetector extends AbstractDetector
Date: Thu, 18 Aug 2022 13:35:24 +0200
Subject: [PATCH 18/29] Updated .gitignore
Added .idea/ and orekit.iml in the .gitignore
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index bb247c390..08e36c564 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@ target
/build
/lib
*.class
+.idea/
+orekit.iml
--
GitLab
From 9afe87bc3ffe27a3162233bc7ed24aae0ed3543b Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Thu, 18 Aug 2022 14:35:52 +0200
Subject: [PATCH 19/29] ExtremumApproachDetectorTest
Fixed the tests so that they are similar to the Orekit philosophy.
Removed previously added dependencies such as AssertJ and JUnit5.
---
pom.xml | 12 ---------
.../events/ExtremumApproachDetectorTest.java | 25 +++++++++----------
2 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/pom.xml b/pom.xml
index 96e3fcc58..74ced757e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -406,18 +406,6 @@
testfalse
-
- org.junit.jupiter
- junit-jupiter
- 5.8.1
- test
-
-
- org.assertj
- assertj-core
- 3.23.1
- test
-
diff --git a/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java b/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
index 15a1b76fb..e548ae6d1 100644
--- a/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
+++ b/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
@@ -16,10 +16,8 @@
*/
package org.orekit.propagation.events;
-import org.assertj.core.api.Assertions;
import org.hipparchus.util.FastMath;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
+import org.junit.Assert;import org.junit.Test;
import org.orekit.Utils;
import org.orekit.bodies.CelestialBodyFactory;
import org.orekit.frames.Frame;
@@ -34,13 +32,13 @@ import org.orekit.propagation.events.handlers.StopOnEvent;
import org.orekit.time.AbsoluteDate;
import org.orekit.utils.PVCoordinatesProvider;
-import static org.assertj.core.api.Assertions.withPrecision;
-
public class ExtremumApproachDetectorTest {
+ /**
+ * Test the detector on a keplerian orbit and detect extremum approach with Earth.
+ */
@Test
- @DisplayName("Test the detector on a keplerian orbit and detect extremum approach with Earth.")
- void Should_stop_propagation_at_closest_approach_by_default() {
+ public void testStopPropagationClosestApproachByDefault() {
// Given
Utils.setDataRoot("regular-data");
@@ -72,14 +70,16 @@ public class ExtremumApproachDetectorTest {
propagator.propagate(initialDate.shiftedBy(orbit.getKeplerianPeriod() * 2));
// Then
- Assertions.assertThat(stateAtEvent.getDate().durationFrom(initialDate))
- .isEqualTo(orbit.getKeplerianPeriod(), withPrecision(2.0e-12));
+ Assert.assertEquals(stateAtEvent.getDate().durationFrom(initialDate),orbit.getKeplerianPeriod(),1e-9);
}
+ /**
+ * Test the detector on a keplerian orbit and detect extremum approach with Earth.
+ */
@Test
- @DisplayName("Test the detector on a keplerian orbit and detect extremum approach with Earth.")
- void Should_stop_propagation_at_farthest_approach_with_handler() {
+ public void testStopPropagationFarthestApproachWithHandler() {
+
// Given
Utils.setDataRoot("regular-data");
@@ -112,8 +112,7 @@ public class ExtremumApproachDetectorTest {
propagator.propagate(initialDate.shiftedBy(orbit.getKeplerianPeriod() * 2));
// Then
- Assertions.assertThat(stateAtEvent.getDate().durationFrom(initialDate))
- .isEqualTo(orbit.getKeplerianPeriod() / 2, withPrecision(1.27798E-8));
+ Assert.assertEquals(stateAtEvent.getDate().durationFrom(initialDate),orbit.getKeplerianPeriod() / 2,1e-7);
}
}
\ No newline at end of file
--
GitLab
From aca1fdf0782bdb9e4ca8c68b34d03cb0ae1116c6 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Wed, 24 Aug 2022 13:36:05 +0200
Subject: [PATCH 20/29] Added IntelliJ files to .gitignore
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index bb247c390..85a319caa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@ target
/build
/lib
*.class
+.idea/
+orekit.iml
\ No newline at end of file
--
GitLab
From 8b6e67d71d4e421ff431a503014025bb92f0de86 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Thu, 25 Aug 2022 13:31:53 +0200
Subject: [PATCH 21/29] Fixed checkstyle issue
---
.../org/orekit/propagation/events/ExtremumApproachDetector.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index 18eb0acf5..f2ea0fa55 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
package org.orekit.propagation.events;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
--
GitLab
From d341d5208c9b432382899aa10c142d53dc904e8b Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Thu, 8 Sep 2022 15:14:17 +0200
Subject: [PATCH 22/29] Updated changes.xml
---
src/changes/changes.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9e350b749..ff59c8a6c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
Added additional state provider for covariance matrix propagation.
+
+ Added ExtremumApproachDetector.
+
Added constructor to AggregateBoundedPropagator for more control over which
propagator is used.
--
GitLab
From e0bc6fa2f209a223bc80f6147e223212f2a35703 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Fri, 23 Sep 2022 17:31:11 +0200
Subject: [PATCH 23/29] Updated develop
---
.../events/ElevationExtremumDetectorTest.java | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/test/java/org/orekit/propagation/events/ElevationExtremumDetectorTest.java b/src/test/java/org/orekit/propagation/events/ElevationExtremumDetectorTest.java
index d1c5afc93..56c0839ad 100644
--- a/src/test/java/org/orekit/propagation/events/ElevationExtremumDetectorTest.java
+++ b/src/test/java/org/orekit/propagation/events/ElevationExtremumDetectorTest.java
@@ -18,9 +18,9 @@ package org.orekit.propagation.events;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.orekit.Utils;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.bodies.OneAxisEllipsoid;
@@ -57,10 +57,10 @@ public class ElevationExtremumDetectorTest {
final EventSlopeFilter maxElevationDetector =
new EventSlopeFilter(raw, FilterType.TRIGGER_ONLY_DECREASING_EVENTS);
- Assert.assertEquals(60.0, raw.getMaxCheckInterval(), 1.0e-15);
- Assert.assertEquals(1.0e-6, raw.getThreshold(), 1.0e-15);
- Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, raw.getMaxIterationCount());
- Assert.assertEquals("test", raw.getTopocentricFrame().getName());
+ Assertions.assertEquals(60.0, raw.getMaxCheckInterval(), 1.0e-15);
+ Assertions.assertEquals(1.0e-6, raw.getThreshold(), 1.0e-15);
+ Assertions.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, raw.getMaxIterationCount());
+ Assertions.assertEquals("test", raw.getTopocentricFrame().getName());
final TimeScale utc = TimeScalesFactory.getUTC();
final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
@@ -92,15 +92,15 @@ public class ElevationExtremumDetectorTest {
if (e0 > FastMath.toRadians(5.0)) {
++visibleEvents;
}
- Assert.assertTrue(e0 > eMinus);
- Assert.assertTrue(e0 > ePlus);
+ Assertions.assertTrue(e0 > eMinus);
+ Assertions.assertTrue(e0 > ePlus);
}
- Assert.assertEquals(15, logger.getLoggedEvents().size());
- Assert.assertEquals( 6, visibleEvents);
+ Assertions.assertEquals(15, logger.getLoggedEvents().size());
+ Assertions.assertEquals( 6, visibleEvents);
}
- @Before
+ @BeforeEach
public void setUp() {
Utils.setDataRoot("regular-data");
}
--
GitLab
From cb0d71739b6e2595a2360ab94ff6cfc3463ad979 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Fri, 23 Sep 2022 17:31:49 +0200
Subject: [PATCH 24/29] Migrated ExtremumApproachDetectorTest to JUnit5
---
.../propagation/events/ExtremumApproachDetectorTest.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java b/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
index e548ae6d1..ccb6329dd 100644
--- a/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
+++ b/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
@@ -17,7 +17,8 @@
package org.orekit.propagation.events;
import org.hipparchus.util.FastMath;
-import org.junit.Assert;import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.orekit.Utils;
import org.orekit.bodies.CelestialBodyFactory;
import org.orekit.frames.Frame;
@@ -70,7 +71,7 @@ public class ExtremumApproachDetectorTest {
propagator.propagate(initialDate.shiftedBy(orbit.getKeplerianPeriod() * 2));
// Then
- Assert.assertEquals(stateAtEvent.getDate().durationFrom(initialDate),orbit.getKeplerianPeriod(),1e-9);
+ Assertions.assertEquals(stateAtEvent.getDate().durationFrom(initialDate),orbit.getKeplerianPeriod(),1e-9);
}
@@ -112,7 +113,7 @@ public class ExtremumApproachDetectorTest {
propagator.propagate(initialDate.shiftedBy(orbit.getKeplerianPeriod() * 2));
// Then
- Assert.assertEquals(stateAtEvent.getDate().durationFrom(initialDate),orbit.getKeplerianPeriod() / 2,1e-7);
+ Assertions.assertEquals(stateAtEvent.getDate().durationFrom(initialDate),orbit.getKeplerianPeriod() / 2,1e-7);
}
-}
\ No newline at end of file
+}
--
GitLab
From e3ffaa1cc272d9dff03338bc69de2718a06cb010 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Mon, 26 Sep 2022 09:45:04 +0200
Subject: [PATCH 25/29] Improved documentation for merge request !293
---
src/changes/changes.xml | 3 +
.../events/ExtremumApproachDetector.java | 87 +++++++++++++------
.../events/ExtremumApproachDetectorTest.java | 12 +++
3 files changed, 76 insertions(+), 26 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5c973b7bd..62ed35696 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -33,6 +33,9 @@
Migrated all tests from JUnit4 to JUnit5.
+
+ Added ExtremumApproachEventDetector.
+
Added constructor to AggregateBoundedPropagator for more control over which
propagator is used.
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index f2ea0fa55..cb0147889 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -19,6 +19,7 @@ package org.orekit.propagation.events;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.ode.events.Action;
+import org.orekit.propagation.PropagatorsParallelizer;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.events.handlers.EventHandler;
import org.orekit.propagation.events.handlers.StopOnIncreasing;
@@ -27,58 +28,91 @@ import org.orekit.utils.PVCoordinatesProvider;
/**
* Finder for extremum approach events.
- *
This class finds extremum approach events (i.e. closest or farthest approach).
- *
The default implementation behavior is to {@link Action#CONTINUE continue}
- * propagation at farthest approach and to {@link Action#STOP stop} propagation at closest approach. This can be changed
- * by calling {@link #withHandler(EventHandler)} after construction.
- *
It is also possible to detect solely one type of event using an {@link EventSlopeFilter event slope filter}. For
+ *
+ * This class finds extremum approach events (i.e. closest or farthest approach).
+ *
+ *
+ * The default implementation behavior is to {@link Action#CONTINUE continue} propagation at farthest approach and to
+ * {@link Action#STOP stop} propagation at closest approach. This can be changed by calling
+ * {@link #withHandler(EventHandler)} after construction (go to the end of the documentation to see an example).
+ *
+ *
+ * As this detector needs two objects (moving relative to each other), it embeds one
+ * {@link PVCoordinatesProvider coordinates provider} for the secondary object and is registered as an event detector in
+ * the propagator of the primary object. The secondary object {@link PVCoordinatesProvider coordinates provider} will
+ * therefore be driven by this detector (and hence by the propagator in which this detector is registered).
+ *
+ *
+ * In order to avoid infinite recursion, care must be taken to have the secondary object provider being completely
+ * independent from anything else. In particular, if the provider is a propagator, it should not be run
+ * together in a {@link PropagatorsParallelizer propagators parallelizer} with the propagator this detector is
+ * registered in. It is fine however to configure two separate propagators PsA and PsB with similar settings for the
+ * secondary object and one propagator Pm for the primary object and then use Psa in this detector registered within Pm
+ * while Pm and Psb are run in the context of a {@link PropagatorsParallelizer propagators parallelizer}.
+ *
+ *
+ * For efficiency reason during the event search loop, it is recommended to have the secondary provider be an analytical
+ * propagator or an ephemeris. A numerical propagator as a secondary propagator works but is expected to be
+ * computationally costly.
+ *
+ *
+ * Also, it is possible to detect solely one type of event using an {@link EventSlopeFilter event slope filter}. For
* example in order to only detect closest approach, one should type the following :
*
{@code
- * ExtremumApproachDetector extremumApproachDetector = new ExtremumApproachDetector(otherPVProvider);
+ * ExtremumApproachDetector extremumApproachDetector = new ExtremumApproachDetector(secondaryPVProvider);
* EventDetector closeApproachDetector = new EventSlopeFilter(extremumApproachDetector,FilterType.TRIGGER_ONLY_INCREASING_EVENTS);
- * }
+ * }
+ *
*
- *
- * @author Vincent Cucchietti
* @see org.orekit.propagation.Propagator#addEventDetector(EventDetector)
* @see EventSlopeFilter
* @see FilterType
+ * @author Vincent Cucchietti
+ * @since 11.3
*/
public class ExtremumApproachDetector extends AbstractDetector {
/**
* PVCoordinates provider of the other object with which we want to find out the extremum approach.
+ *
+ * By default, the implemented behavior is to {@link Action#CONTINUE continue} propagation at farthest approach and
+ * to {@link Action#STOP stop} propagation at closest approach.
+ *
*/
- private final PVCoordinatesProvider otherPVProvider;
+ private final PVCoordinatesProvider secondaryPVProvider;
/**
* Constructor with default values.
*
- * @param otherPVProvider PVCoordinates provider of the other object with which we want to find out the extremum
- * approach.
+ * @param secondaryPVProvider PVCoordinates provider of the other object with which we want to find out the extremum
+ * approach.
*/
- public ExtremumApproachDetector(final PVCoordinatesProvider otherPVProvider) {
- this(DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER, new StopOnIncreasing<>(), otherPVProvider);
+ public ExtremumApproachDetector(final PVCoordinatesProvider secondaryPVProvider) {
+ this(DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER, new StopOnIncreasing<>(), secondaryPVProvider);
}
/**
* Constructor.
*
- * @param maxCheck Maximum checking interval (s).
- * @param threshold Convergence threshold (s).
- * @param maxIter Maximum number of iterations in the event time search.
- * @param handler Event handler to call at event occurrences.
- * @param otherPVProvider PVCoordinates provider of the other object with which we want to find out the extremum *
- * approach.
+ * @param maxCheck Maximum checking interval (s).
+ * @param threshold Convergence threshold (s).
+ * @param maxIter Maximum number of iterations in the event time search.
+ * @param handler Event handler to call at event occurrences.
+ * @param secondaryPVProvider PVCoordinates provider of the other object with which we want to find out the extremum
+ * * approach.
*/
public ExtremumApproachDetector(
final double maxCheck, final double threshold, final int maxIter,
- final EventHandler super ExtremumApproachDetector> handler, final PVCoordinatesProvider otherPVProvider) {
+ final EventHandler super ExtremumApproachDetector> handler,
+ final PVCoordinatesProvider secondaryPVProvider) {
super(maxCheck, threshold, maxIter, handler);
- this.otherPVProvider = otherPVProvider;
+ this.secondaryPVProvider = secondaryPVProvider;
}
- /** {@inheritDoc} */
+ /**
+ * The {@code g} is positive when the primary object is getting further away from the secondary object and is
+ * negative when it is getting closer to it.
+ */
public double g(final SpacecraftState s) {
final PVCoordinates deltaPV = deltaPV(s);
return Vector3D.dotProduct(deltaPV.getPosition(), deltaPV.getVelocity());
@@ -86,17 +120,18 @@ public class ExtremumApproachDetector extends AbstractDetector newHandler) {
- return new ExtremumApproachDetector(newMaxCheck, newThreshold, newMaxIter, newHandler, otherPVProvider);
+ final EventHandler super ExtremumApproachDetector> newHandler) {
+ return new ExtremumApproachDetector(newMaxCheck, newThreshold, newMaxIter, newHandler, secondaryPVProvider);
}
}
diff --git a/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java b/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
index ccb6329dd..faa45e496 100644
--- a/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
+++ b/src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java
@@ -41,8 +41,10 @@ public class ExtremumApproachDetectorTest {
@Test
public void testStopPropagationClosestApproachByDefault() {
// Given
+ // Loading Orekit data
Utils.setDataRoot("regular-data");
+ // Generating orbit
final AbsoluteDate initialDate = new AbsoluteDate();
final Frame frame = FramesFactory.getEME2000();
final double mu = 398600e9; //m**3/s**2
@@ -58,11 +60,16 @@ public class ExtremumApproachDetectorTest {
final double anomaly = FastMath.toRadians(0); //rad
final Orbit orbit =
new KeplerianOrbit(a, e, i, pa, raan, anomaly, PositionAngle.TRUE, frame, initialDate, mu);
+ System.out.println("Keplerian period is : ");
+ System.out.println(orbit.getKeplerianPeriod());
+ // Will detect extremum approaches with Earth
final PVCoordinatesProvider earthPVProvider = CelestialBodyFactory.getEarth();
+ // Initializing detector
final ExtremumApproachDetector detector = new ExtremumApproachDetector(earthPVProvider);
+ // Initializing propagator
final Propagator propagator = new KeplerianPropagator(orbit);
propagator.addEventDetector(detector);
@@ -82,8 +89,10 @@ public class ExtremumApproachDetectorTest {
public void testStopPropagationFarthestApproachWithHandler() {
// Given
+ // Loading Orekit data
Utils.setDataRoot("regular-data");
+ // Generating orbit
final AbsoluteDate initialDate = new AbsoluteDate();
final Frame frame = FramesFactory.getEME2000();
final double mu = 398600e9; //m**3/s**2
@@ -100,11 +109,14 @@ public class ExtremumApproachDetectorTest {
final Orbit orbit =
new KeplerianOrbit(a, e, i, pa, raan, anomaly, PositionAngle.TRUE, frame, initialDate, mu);
+ // Will detect extremum approaches with Earth
final PVCoordinatesProvider earthPVProvider = CelestialBodyFactory.getEarth();
+ // Initializing detector with custom handler
final ExtremumApproachDetector detector =
new ExtremumApproachDetector(earthPVProvider).withHandler(new StopOnEvent<>());
+ // Initializing propagator
final Propagator propagator = new KeplerianPropagator(orbit);
propagator.addEventDetector(detector);
--
GitLab
From a45dceb948fae2845f00b47e37f5bdd0b5e6b7d9 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Mon, 26 Sep 2022 09:55:45 +0200
Subject: [PATCH 26/29] Minor change to documentation.
---
.../orekit/propagation/events/ExtremumApproachDetector.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index cb0147889..3a9bf1e67 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -42,14 +42,14 @@ import org.orekit.utils.PVCoordinatesProvider;
* the propagator of the primary object. The secondary object {@link PVCoordinatesProvider coordinates provider} will
* therefore be driven by this detector (and hence by the propagator in which this detector is registered).
*
- *
+ *
* In order to avoid infinite recursion, care must be taken to have the secondary object provider being completely
* independent from anything else. In particular, if the provider is a propagator, it should not be run
* together in a {@link PropagatorsParallelizer propagators parallelizer} with the propagator this detector is
* registered in. It is fine however to configure two separate propagators PsA and PsB with similar settings for the
* secondary object and one propagator Pm for the primary object and then use Psa in this detector registered within Pm
* while Pm and Psb are run in the context of a {@link PropagatorsParallelizer propagators parallelizer}.
- *
+ *
*
* For efficiency reason during the event search loop, it is recommended to have the secondary provider be an analytical
* propagator or an ephemeris. A numerical propagator as a secondary propagator works but is expected to be
--
GitLab
From b9577609bef687ff03a5c00625700b9ef4fe2854 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Mon, 26 Sep 2022 10:02:48 +0200
Subject: [PATCH 27/29] Fixed checkstyle in javadoc.
---
.../orekit/propagation/events/ExtremumApproachDetector.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index 3a9bf1e67..038e10e46 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -112,6 +112,10 @@ public class ExtremumApproachDetector extends AbstractDetector
Date: Mon, 26 Sep 2022 10:08:34 +0200
Subject: [PATCH 28/29] Improved javadoc for merge request !293.
---
.../propagation/events/ExtremumApproachDetector.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index 038e10e46..7b46467cf 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -74,15 +74,15 @@ public class ExtremumApproachDetector extends AbstractDetector
- * By default, the implemented behavior is to {@link Action#CONTINUE continue} propagation at farthest approach and
- * to {@link Action#STOP stop} propagation at closest approach.
- *
*/
private final PVCoordinatesProvider secondaryPVProvider;
/**
* Constructor with default values.
+ *
+ * By default, the implemented behavior is to {@link Action#CONTINUE continue} propagation at farthest approach and
+ * to {@link Action#STOP stop} propagation at closest approach.
+ *
*
* @param secondaryPVProvider PVCoordinates provider of the other object with which we want to find out the extremum
* approach.
@@ -93,6 +93,10 @@ public class ExtremumApproachDetector extends AbstractDetector
+ * By default, the implemented behavior is to {@link Action#CONTINUE continue} propagation at farthest approach and
+ * to {@link Action#STOP stop} propagation at closest approach.
+ *
*
* @param maxCheck Maximum checking interval (s).
* @param threshold Convergence threshold (s).
--
GitLab
From 284d3d8a6b6349901cea66ebb8a44ca1b8a8ab91 Mon Sep 17 00:00:00 2001
From: Vincent Cucchietti
Date: Thu, 29 Sep 2022 08:53:24 +0200
Subject: [PATCH 29/29] Improved Javadoc of ExtremumApproachDetector
Fixed missing title in computeDeltaPV method.
Changed javadoc in custom constructor.
---
.../events/ExtremumApproachDetector.java | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
index 7b46467cf..e61c2d609 100644
--- a/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
+++ b/src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java
@@ -64,6 +64,7 @@ import org.orekit.utils.PVCoordinatesProvider;
* }
*
*
+ *
* @see org.orekit.propagation.Propagator#addEventDetector(EventDetector)
* @see EventSlopeFilter
* @see FilterType
@@ -94,8 +95,7 @@ public class ExtremumApproachDetector extends AbstractDetector
- * By default, the implemented behavior is to {@link Action#CONTINUE continue} propagation at farthest approach and
- * to {@link Action#STOP stop} propagation at closest approach.
+ * This constructor is to be used if the user wants to change the default behavior of the detector.
*
*
* @param maxCheck Maximum checking interval (s).
@@ -104,6 +104,7 @@ public class ExtremumApproachDetector extends AbstractDetector newHandler) {
+ final EventHandler super ExtremumApproachDetector> newHandler) {
return new ExtremumApproachDetector(newMaxCheck, newThreshold, newMaxIter, newHandler, secondaryPVProvider);
}
}
--
GitLab