Skip to content

Finder for sub-satellite point eclipse related events #26

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 61 additions & 10 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, detection flag. */
private final boolean subSatellitePoint;

/** 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,47 @@ 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, false);
}

/**
* Setup the detector to penumbra detection.
* Setup the detector to full umbra detection for the sub-satellite point.
* <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()
* @see #withPenumbra()
* @since 6.1
*/
public EclipseDetector UmbraWithSSP() {
return new EclipseDetector(getMaxCheckInterval(), getThreshold(), getMaxIterationCount(), getHandler(),
occulted, occultedRadius, occulting, true, true);
}

/**
* 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 #penumbraWithSSP()
*/
public EclipseDetector withPenumbra() {
return new EclipseDetector(getMaxCheckInterval(), getThreshold(), getMaxIterationCount(), getHandler(),
occulted, occultedRadius, occulting, false);
occulted, occultedRadius, occulting, false, false);
}

/**
* Setup the detector to penumbra detection for the sub-satellite point.
* <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 #UmbraWithSSP()
*/
public EclipseDetector penumbraWithSSP() {
return new EclipseDetector(getMaxCheckInterval(), getThreshold(), getMaxIterationCount(), getHandler(),
occulted, occultedRadius, occulting, false, true);
}

/** Getter for the occulting body.
Expand Down Expand Up @@ -169,6 +204,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 +221,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 = FramesFactory.getEME2000();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inertial frame should be extracted from SpacecraftState rather than hard-coded to EME2000.
Otherwise, the s.getPVCoordinates().getPosition() in the following line will be inconsistent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it.

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