From e7dc121f7e4169008d741992ed55e3d1d84361c3 Mon Sep 17 00:00:00 2001 From: Vincent Cucchietti Date: Wed, 17 Aug 2022 10:00:32 +0200 Subject: [PATCH 01/29] Reset develop branch --- .idea/checkstyle-idea.xml | 15 ++++ .idea/compiler.xml | 22 ++++++ .idea/encodings.xml | 7 ++ .idea/jarRepositories.xml | 25 +++++++ .idea/misc.xml | 12 +++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 153 ++++++++++++++++++++++++++++++++++++++ orekit.iml | 7 ++ 8 files changed, 247 insertions(+) create mode 100644 .idea/checkstyle-idea.xml create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 orekit.iml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml new file mode 100644 index 000000000..23198ed84 --- /dev/null +++ b/.idea/checkstyle-idea.xml @@ -0,0 +1,15 @@ + + + + 10.3.1 + JavaOnly + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 000000000..ab13e2e93 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..aa00ffab7 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 000000000..a9d927cf5 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..4555257d3 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000..34bab296c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "last_opened_file_path": "/home/vcucchie/git/forks/orekit/src/main/java/org/orekit/compiler", + "settings.editor.selected.configurable": "reference.projectsettings.compiler.excludes" + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1660664828091 + + + + + + + \ No newline at end of file diff --git a/orekit.iml b/orekit.iml new file mode 100644 index 000000000..c3e1ecfed --- /dev/null +++ b/orekit.iml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file -- GitLab From fc3767088c0a0a69a24e4cd50d3da57f4dde3a2f Mon Sep 17 00:00:00 2001 From: Vincent Cucchietti Date: Wed, 17 Aug 2022 10:59:08 +0200 Subject: [PATCH 02/29] Added ExtremumApproachDetector feat: Added the ExtremumApproachDetector which detects farthest/closest approaches with another given PVCoordinatesProvider. test: Added two tests to the ExtremumApproachDetector. --- .idea/compiler.xml | 2 + .idea/workspace.xml | 64 ++++++++--- pom.xml | 12 ++ .../events/ExtremumApproachDetector.java | 85 +++++++++++++++ .../events/ExtremumApproachDetectorTest.java | 103 ++++++++++++++++++ 5 files changed, 252 insertions(+), 14 deletions(-) create mode 100644 src/main/java/org/orekit/propagation/events/ExtremumApproachDetector.java create mode 100644 src/test/java/org/orekit/propagation/events/ExtremumApproachDetectorTest.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml index ab13e2e93..28c706f7a 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,8 @@ + - + + + + + + + + + + + + + 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 @@ test false + + 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 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 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 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 @@