Skip to content
Snippets Groups Projects
Commit 2ee956c0 authored by sesteves's avatar sesteves
Browse files

Luc changes

parent 01e819cf
No related branches found
No related tags found
No related merge requests found
...@@ -78,30 +78,26 @@ public class MultiLayerModel implements AtmosphericRefraction { ...@@ -78,30 +78,26 @@ public class MultiLayerModel implements AtmosphericRefraction {
try { try {
Vector3D pos = satPos; Vector3D pos = satPos;
Vector3D los = satLos; Vector3D los = satLos.normalize();
Vector3D zenith = null;
double previousRefractionIndex = -1; double previousRefractionIndex = -1;
GeodeticPoint gp = ellipsoid.transform(satPos, ellipsoid.getBodyFrame(), null); GeodeticPoint gp = ellipsoid.transform(satPos, ellipsoid.getBodyFrame(), null);
for(ConstantRefractionLayer refractionLayer : refractionLayers) { for (ConstantRefractionLayer refractionLayer : refractionLayers) {
if(refractionLayer.getLowestAltitude() > gp.getAltitude()) { if (refractionLayer.getLowestAltitude() > gp.getAltitude()) {
continue; continue;
} }
if (previousRefractionIndex > 0) { if (previousRefractionIndex > 0) {
// get new los // get new los by applying Snell's law at atmosphere layers interfaces
final double theta1 = FastMath.toRadians(Vector3D.angle(los, zenith)); // we avoid computing sequences of inverse-trigo/trigo/inverse-trigo functions
final double theta2 = FastMath.asin(previousRefractionIndex * FastMath.sin(theta1) / // we just use linear algebra and square roots, it is faster and more accurate
refractionLayer.getRefractionIndex()); final double n1On2 = previousRefractionIndex / refractionLayer.getRefractionIndex();
final double k = n1On2 * Vector3D.dotProduct(los, gp.getZenith());
los = new Vector3D(n1On2, los,
-k - FastMath.sqrt(1 + k * k - n1On2 * n1On2), gp.getZenith());
final double cosTheta1 = FastMath.cos(theta1);
final double cosTheta2 = FastMath.cos(theta2);
final double a = FastMath.sqrt((1 - cosTheta2 * cosTheta2) / (1 - cosTheta1 * cosTheta1));
final double b = a * cosTheta1 - cosTheta2;
los = new Vector3D(a, los, b, zenith);
} }
if (rawIntersection.getAltitude() > refractionLayer.getLowestAltitude()) { if (rawIntersection.getAltitude() > refractionLayer.getLowestAltitude()) {
...@@ -111,7 +107,6 @@ public class MultiLayerModel implements AtmosphericRefraction { ...@@ -111,7 +107,6 @@ public class MultiLayerModel implements AtmosphericRefraction {
// get intersection point // get intersection point
pos = ellipsoid.pointAtAltitude(pos, los, refractionLayer.getLowestAltitude()); pos = ellipsoid.pointAtAltitude(pos, los, refractionLayer.getLowestAltitude());
gp = ellipsoid.transform(pos, ellipsoid.getBodyFrame(), null); gp = ellipsoid.transform(pos, ellipsoid.getBodyFrame(), null);
zenith = gp.getZenith();
previousRefractionIndex = refractionLayer.getRefractionIndex(); previousRefractionIndex = refractionLayer.getRefractionIndex();
} }
......
...@@ -25,11 +25,7 @@ import org.orekit.rugged.errors.RuggedException; ...@@ -25,11 +25,7 @@ import org.orekit.rugged.errors.RuggedException;
import org.orekit.rugged.intersection.AbstractAlgorithmTest; import org.orekit.rugged.intersection.AbstractAlgorithmTest;
import org.orekit.rugged.intersection.IntersectionAlgorithm; import org.orekit.rugged.intersection.IntersectionAlgorithm;
import org.orekit.rugged.intersection.duvenhage.DuvenhageAlgorithm; import org.orekit.rugged.intersection.duvenhage.DuvenhageAlgorithm;
import org.orekit.rugged.intersection.duvenhage.MinMaxTreeTile;
import org.orekit.rugged.intersection.duvenhage.MinMaxTreeTileFactory;
import org.orekit.rugged.raster.Tile;
import org.orekit.rugged.raster.TileUpdater; import org.orekit.rugged.raster.TileUpdater;
import org.orekit.rugged.raster.TilesCache;
import org.orekit.rugged.utils.NormalizedGeodeticPoint; import org.orekit.rugged.utils.NormalizedGeodeticPoint;
public class MultiLayerModelTest extends AbstractAlgorithmTest { public class MultiLayerModelTest extends AbstractAlgorithmTest {
...@@ -49,8 +45,9 @@ public class MultiLayerModelTest extends AbstractAlgorithmTest { ...@@ -49,8 +45,9 @@ public class MultiLayerModelTest extends AbstractAlgorithmTest {
double distance = Vector3D.distance(earth.transform(rawIntersection), earth.transform(correctedIntersection)); double distance = Vector3D.distance(earth.transform(rawIntersection), earth.transform(correctedIntersection));
// with the current code, this check fails, the distance is about 800m instead of a couple meters // this is almost a Nadir observation (LOS deviates between 1.4 and 1.6 degrees from vertical)
Assert.assertEquals(0.0, distance, 2.0); // so the refraction correction is small
Assert.assertEquals(0.0553797, distance, 1.0e-6);
} }
@Override @Override
......
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