Skip to content
Snippets Groups Projects
Commit 39ba3e87 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

New test and simplified code.

parent 046af11e
No related branches found
No related tags found
No related merge requests found
......@@ -110,8 +110,8 @@ public class RoughVisibilityEstimator {
final Vector3D point = ellipsoid.transform(groundPoint);
int closeIndex = findClose(last, point);
// check if there are closer points in previous half periods
final int repeat = (int) FastMath.rint(FastMath.PI / rateVSIndices);
// check if there are closer points in previous periods
final int repeat = (int) FastMath.rint(2.0 * FastMath.PI / rateVSIndices);
for (int index = closeIndex - repeat; index > 0; index -= repeat) {
final int otherIndex = findClose(index, point);
if (otherIndex != closeIndex &&
......@@ -121,7 +121,7 @@ public class RoughVisibilityEstimator {
}
}
// check if there are closer points in next half periods
// check if there are closer points in next periods
for (int index = closeIndex + repeat; index < pvGround.size(); index += repeat) {
final int otherIndex = findClose(index, point);
if (otherIndex != closeIndex &&
......@@ -160,6 +160,10 @@ public class RoughVisibilityEstimator {
}
/** Estimate angular motion needed to go past test point.
* <p>
* This estimation is quite crude. The sub-satellite point is properly on the
* ellipsoid surface, but we compute the angle assuming a spherical shape.
* </p>
* @param subSatellite current sub-satellite position-velocity
* @param point test point
* @return angular motion to go past test point (positive is
......@@ -170,12 +174,9 @@ public class RoughVisibilityEstimator {
final Vector3D ssP = subSatellite.getPosition();
final Vector3D momentum = subSatellite.getMomentum();
final double y = Vector3D.dotProduct(point, Vector3D.crossProduct(momentum, ssP).normalize());
final double x = Vector3D.dotProduct(point, ssP.normalize());
// find phase angle around momentum
final Vector3D yAxis = Vector3D.crossProduct(momentum, ssP).normalize();
final Vector3D xAxis = Vector3D.crossProduct(yAxis, momentum).normalize();
final double y = Vector3D.dotProduct(point, yAxis);
final double x = Vector3D.dotProduct(point, xAxis);
return FastMath.atan2(y, x);
}
......
......@@ -88,6 +88,34 @@ public class RoughVisibilityEstimatorTest {
}
@Test
public void testOneOrbitsSpan()
throws RuggedException, OrekitException, URISyntaxException {
String path = getClass().getClassLoader().getResource("orekit-data").toURI().getPath();
DataProvidersManager.getInstance().addProvider(new DirectoryCrawler(new File(path)));
BodyShape earth = createEarth();
NormalizedSphericalHarmonicsProvider gravityField = createGravityField();
Orbit orbit = createOrbit(gravityField.getMu());
Propagator propagator = createPropagator(earth, gravityField, orbit);
final List<TimeStampedPVCoordinates> pv = new ArrayList<TimeStampedPVCoordinates>();
propagator.setMasterMode(1.0, new OrekitFixedStepHandler() {
public void init(SpacecraftState s0, AbsoluteDate t) {
}
public void handleStep(SpacecraftState currentState, boolean isLast) {
pv.add(currentState.getPVCoordinates());
}
});
propagator.propagate(orbit.getDate().shiftedBy(orbit.getKeplerianPeriod()));
RoughVisibilityEstimator estimator = new RoughVisibilityEstimator(ellipsoid, orbit.getFrame(), pv);
AbsoluteDate d = estimator.estimateVisibility(new GeodeticPoint(FastMath.toRadians(43.303),
FastMath.toRadians(-46.126),
0.0));
Assert.assertEquals("2012-01-01T01:02:39.123", d.toString(TimeScalesFactory.getUTC()));
}
private BodyShape createEarth()
throws OrekitException {
return new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment