Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finder for sub-satellite point eclipse related events #26

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 45 additions & 11 deletions src/main/java/org/orekit/propagation/events/EclipseDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.ode.events.Action;
import org.hipparchus.util.FastMath;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.bodies.OneAxisEllipsoid;
import org.orekit.frames.Frame;
import org.orekit.frames.FramesFactory;
import org.orekit.propagation.SpacecraftState;
import org.orekit.propagation.events.handlers.EventHandler;
import org.orekit.propagation.events.handlers.StopOnIncreasing;
Expand Down Expand Up @@ -61,6 +64,9 @@ public class EclipseDetector extends AbstractDetector<EclipseDetector> {

/** Umbra, if true, or penumbra, if false, detection flag. */
private final boolean totalEclipse;

/** Sub-satellite point, if true, or Spacecraft, if false (default), flag. */
private boolean subSatellitePoint = false;

/** Build a new eclipse detector.
* <p>The new instance is a total eclipse (umbra) detector with default
Expand All @@ -75,7 +81,7 @@ public EclipseDetector(final PVCoordinatesProvider occulted, final double occul
final OneAxisEllipsoid occulting) {
this(DEFAULT_MAXCHECK, DEFAULT_THRESHOLD, DEFAULT_MAX_ITER,
new StopOnIncreasing<EclipseDetector>(),
occulted, occultedRadius, occulting, true);
occulted, occultedRadius, occulting, true, false);
}

/** Private constructor with full parameters.
Expand All @@ -92,29 +98,32 @@ public EclipseDetector(final PVCoordinatesProvider occulted, final double occul
* @param occultedRadius the radius of the body to be occulted in meters
* @param occulting the occulting body
* @param totalEclipse umbra (true) or penumbra (false) detection flag
* @param subSatellitePoint Sub-satellite point (true) or Spacecraft (false) flag
* @since 10.0
*/
private EclipseDetector(final double maxCheck, final double threshold,
final int maxIter, final EventHandler<? super EclipseDetector> handler,
final PVCoordinatesProvider occulted, final double occultedRadius,
final OneAxisEllipsoid occulting, final boolean totalEclipse) {
final OneAxisEllipsoid occulting, final boolean totalEclipse, final boolean subSatellitePoint) {
super(maxCheck, threshold, maxIter, handler);
this.occulted = occulted;
this.occultedRadius = FastMath.abs(occultedRadius);
this.occulting = occulting;
this.totalEclipse = totalEclipse;
this.subSatellitePoint = subSatellitePoint;

}

/** {@inheritDoc} */
@Override
protected EclipseDetector create(final double newMaxCheck, final double newThreshold,
final int nawMaxIter, final EventHandler<? super EclipseDetector> newHandler) {
return new EclipseDetector(newMaxCheck, newThreshold, nawMaxIter, newHandler,
occulted, occultedRadius, occulting, totalEclipse);
occulted, occultedRadius, occulting, totalEclipse, subSatellitePoint);
}

/**
* Setup the detector to full umbra detection.
* Setup the detector to full umbra detection for the satellite.
* <p>
* This will override a penumbra/umbra flag if it has been configured previously.
* </p>
Expand All @@ -124,21 +133,30 @@ protected EclipseDetector create(final double newMaxCheck, final double newThres
*/
public EclipseDetector withUmbra() {
return new EclipseDetector(getMaxCheckInterval(), getThreshold(), getMaxIterationCount(), getHandler(),
occulted, occultedRadius, occulting, true);
occulted, occultedRadius, occulting, true, subSatellitePoint);
}

/**
* Setup the detector to penumbra detection.
* Setup the detector to penumbra detection for the satellite.
* <p>
* This will override a penumbra/umbra flag if it has been configured previously.
* </p>
* @return a new detector with updated configuration (the instance is not changed)
* @see #withUmbra()
* @since 6.1
* @see #penumbraWithSSP()
*/
public EclipseDetector withPenumbra() {
return new EclipseDetector(getMaxCheckInterval(), getThreshold(), getMaxIterationCount(), getHandler(),
occulted, occultedRadius, occulting, false);
occulted, occultedRadius, occulting, false, subSatellitePoint);
}

/**
* Setup the detector for the sub-satellite point.
* <p>
* @return a new detector with updated configuration (the instance is not changed)
*/
public EclipseDetector withSubSatellitePoint() {
return new EclipseDetector(getMaxCheckInterval(), getThreshold(), getMaxIterationCount(), getHandler(),
occulted, occultedRadius, occulting, totalEclipse, true);
}

/** Getter for the occulting body.
Expand Down Expand Up @@ -169,6 +187,14 @@ public double getOccultedRadius() {
public boolean getTotalEclipse() {
return totalEclipse;
}

/** Get the sub-satellite point flag.
* @return the sub-satellite point flag (true for sub-satellite point,
* false for satellite)
*/
public boolean getSubSatellitePoint() {
return subSatellitePoint;
}

/** Compute the value of the switching function.
* This function becomes negative when entering the region of shadow
Expand All @@ -178,7 +204,15 @@ public boolean getTotalEclipse() {
*/
public double g(final SpacecraftState s) {
final Vector3D pted = occulted.getPVCoordinates(s.getDate(), occulting.getBodyFrame()).getPosition();
final Vector3D psat = s.getPVCoordinates(occulting.getBodyFrame()).getPosition();
Vector3D psat = null;
if (subSatellitePoint) {
Frame inertialFrame = s.getFrame();
GeodeticPoint gp = getOcculting().transform(s.getPVCoordinates().getPosition(), inertialFrame, s.getDate());
GeodeticPoint gpSSP = new GeodeticPoint(gp.getLatitude(), gp.getLongitude(), 1);
psat = getOcculting().transform(gpSSP);
} else {
psat = s.getPVCoordinates(occulting.getBodyFrame()).getPosition();
}
final Vector3D plimb = occulting.pointOnLimb(psat, pted);
final Vector3D ps = psat.subtract(pted);
final Vector3D pi = psat.subtract(plimb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ public void testPenumbra() {
final SpacecraftState finalState = propagator.propagate(iniDate.shiftedBy(6000));
Assert.assertEquals(4388.155852, finalState.getDate().durationFrom(iniDate), 2.0e-6);
}

@Test
public void testSubSatellitePoint() {
EclipseDetector e = new EclipseDetector(sun, sunRadius, earth).
withMaxCheck(60.0).
withThreshold(1.0e-3).
withUmbra().withSubSatellitePoint();
Assert.assertTrue(e.getTotalEclipse());
propagator.addEventDetector(e);
final SpacecraftState finalState = propagator.propagate(iniDate.shiftedBy(6000));
Assert.assertEquals(4815.310605, finalState.getDate().durationFrom(iniDate), 2.0e-6);
}

@Test
public void testWithMethods() {
Expand Down