use of org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet in project Orekit by CS-SI.
the class EllipsoidTessellatorTest method testTooThinRemainingRegion.
@Test
public void testTooThinRemainingRegion() throws OrekitException {
TileAiming aiming = new ConstantAzimuthAiming(ellipsoid, -0.2185);
EllipsoidTessellator tessellator = new EllipsoidTessellator(ellipsoid, aiming, 16);
SphericalPolygonsSet small = buildSimpleZone(1.0e-10, new double[][] { { 32.7342, -16.9407 }, { 32.7415, -16.9422 }, { 32.7481, -16.9463 }, { 32.7531, -16.9528 }, { 32.7561, -16.9608 }, { 32.7567, -16.9696 }, { 32.7549, -16.9781 }, { 32.7508, -16.9855 }, { 32.7450, -16.9909 }, { 32.7379, -16.9937 }, { 32.7305, -16.9937 }, { 32.7235, -16.9909 }, { 32.7177, -16.9855 }, { 32.7136, -16.9781 }, { 32.7118, -16.9696 }, { 32.7124, -16.9608 }, { 32.7154, -16.9528 }, { 32.7204, -16.9463 }, { 32.7269, -16.9422 } });
final double maxWidth = 40000.0;
final double maxLength = 40000.0;
final List<List<Tile>> tiles = tessellator.tessellate(small, maxWidth, maxLength, 0, 0, false, true);
Assert.assertEquals(1, tiles.size());
Assert.assertEquals(1, tiles.get(0).size());
for (final Tile tile : tiles.get(0)) {
Vector3D v0 = ellipsoid.transform(tile.getVertices()[0]);
Vector3D v1 = ellipsoid.transform(tile.getVertices()[1]);
Vector3D v2 = ellipsoid.transform(tile.getVertices()[2]);
Vector3D v3 = ellipsoid.transform(tile.getVertices()[3]);
Assert.assertTrue(Vector3D.distance(v0, v1) < 0.3 * maxLength);
Assert.assertEquals(maxWidth, Vector3D.distance(v1, v2), 0.1);
Assert.assertTrue(Vector3D.distance(v2, v3) < 0.3 * maxLength);
Assert.assertEquals(maxWidth, Vector3D.distance(v3, v0), 0.1);
}
}
use of org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet in project Orekit by CS-SI.
the class FieldOfViewTest method testSerialization.
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
FieldOfView fov = new FieldOfView(new SphericalPolygonsSet(1.0e-12, new S2Point(Vector3D.PLUS_I), new S2Point(Vector3D.PLUS_J), new S2Point(Vector3D.PLUS_K)), 0.001);
Assert.assertEquals(0.5 * FastMath.PI, fov.getZone().getSize(), 1.0e-15);
Assert.assertEquals(1.5 * FastMath.PI, fov.getZone().getBoundarySize(), 1.0e-15);
Assert.assertEquals(0.001, fov.getMargin(), 1.0e-15);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(fov);
Assert.assertTrue(bos.size() > 400);
Assert.assertTrue(bos.size() < 450);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
FieldOfView deserialized = (FieldOfView) ois.readObject();
Assert.assertEquals(0.5 * FastMath.PI, deserialized.getZone().getSize(), 1.0e-15);
Assert.assertEquals(1.5 * FastMath.PI, deserialized.getZone().getBoundarySize(), 1.0e-15);
Assert.assertEquals(0.001, deserialized.getMargin(), 1.0e-15);
}
use of org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet in project Orekit by CS-SI.
the class FootprintOverlapDetectorTest method testSerialization.
@Test
public void testSerialization() throws IOException, ClassNotFoundException, OrekitException {
// observe continental France plus Corsica
final SphericalPolygonsSet france = buildFrance();
// square field of view along Z axis (which is pointing sideways),
// aperture 5° (hence half-aperture 2.5°), 0.001 radians margin
final double alpha = FastMath.toRadians(2.5);
final FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, alpha, 4, 0.001);
double eta = FastMath.acos(FastMath.sin(alpha) * FastMath.sin(alpha));
double theoreticalArea = MathUtils.TWO_PI - 4 * eta;
final FootprintOverlapDetector detector = new FootprintOverlapDetector(fov, earth, france, 50000.0).withMaxCheck(1.0).withThreshold(1.0e-6).withHandler(new ContinueOnEvent<FootprintOverlapDetector>());
Assert.assertEquals(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, ((OneAxisEllipsoid) detector.getBody()).getEquatorialRadius(), 1.0e-12);
Assert.assertEquals(0.001, detector.getFieldOfView().getMargin(), 1.0e-12);
Assert.assertEquals(theoreticalArea, detector.getFieldOfView().getZone().getSize(), 1.0e-12);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(detector);
Assert.assertTrue(bos.size() > 2400);
Assert.assertTrue(bos.size() < 2500);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
FootprintOverlapDetector deserialized = (FootprintOverlapDetector) ois.readObject();
Assert.assertEquals(detector.getZone().getSize(), deserialized.getZone().getSize(), 1.0e-14);
Assert.assertEquals(detector.getZone().getBoundarySize(), deserialized.getZone().getBoundarySize(), 1.0e-14);
Assert.assertEquals(detector.getZone().getTolerance(), deserialized.getZone().getTolerance(), 1.0e-15);
Assert.assertEquals(detector.getMaxCheckInterval(), deserialized.getMaxCheckInterval(), 1.0e-15);
Assert.assertEquals(detector.getThreshold(), deserialized.getThreshold(), 1.0e-15);
Assert.assertEquals(detector.getMaxIterationCount(), deserialized.getMaxIterationCount());
Assert.assertTrue(new RegionFactory<Sphere2D>().difference(detector.getZone(), deserialized.getZone()).isEmpty());
}
use of org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet in project Orekit by CS-SI.
the class FootprintOverlapDetectorTest method testRightForwardView.
@Test
public void testRightForwardView() throws OrekitException, IOException {
propagator.setAttitudeProvider(new LofOffset(initialOrbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(-20.0), FastMath.toRadians(+20.0), 0.0));
// observe continental France plus Corsica
final SphericalPolygonsSet france = buildFrance();
// square field of view along Z axis (which is pointing sideways), aperture 5°, 0° margin
final FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(2.5), 4, 0.0);
final FootprintOverlapDetector detector = new FootprintOverlapDetector(fov, earth, france, 50000.0).withMaxCheck(1.0).withThreshold(1.0e-6).withHandler(new ContinueOnEvent<FootprintOverlapDetector>());
final EventsLogger logger = new EventsLogger();
propagator.addEventDetector(logger.monitorDetector(detector));
// Extrapolate from the initial to the final date
propagator.propagate(initialOrbit.getDate().shiftedBy(635000), initialOrbit.getDate().shiftedBy(735000));
List<LoggedEvent> events = logger.getLoggedEvents();
Assert.assertEquals(8, events.size());
// the first two consecutive close events occur during the same ascending orbit
// we first see Corsica, then lose visibility over the see, then see continental France
// above Mediterranean see, between Illes Balears and Sardigna,
// pointing to Corsica towards North-East
checkEventPair(events.get(0), events.get(1), 639010.0775, 33.9434, 39.2168, 6.5980, 42.0671, 9.0543);
// above Saint-Chamond (Loire), pointing near Saint-Dié-des-Vosges (Vosges) towards North-East
checkEventPair(events.get(2), events.get(3), 639111.1399, 40.8032, 45.4637, 4.5075, 48.3487, 7.1733);
// event is on a descending orbit, so the pointing direction,
// taking roll and pitch offsets, is towards South-West with respect to spacecraft
// above English Channel, pointing near Hanvec (Finistère) towards South-West
checkEventPair(events.get(4), events.get(5), 687772.4531, 27.0852, 50.2693, 0.0493, 48.3243, -4.1510);
// event on an ascending orbit
// above Atlantic ocean, pointing near to île d'Oléron (Charente-Maritime) towards North-East
checkEventPair(events.get(6), events.get(7), 727696.1033, 113.8829, 42.9785, -4.0426, 45.8492, -1.4656);
}
use of org.hipparchus.geometry.spherical.twod.SphericalPolygonsSet in project Orekit by CS-SI.
the class GeographicZoneDetectorTest method buildFrance.
private SphericalPolygonsSet buildFrance() {
final SphericalPolygonsSet continental = buildSimpleZone(new double[][] { { 51.14850, 2.51357 }, { 50.94660, 1.63900 }, { 50.12717, 1.33876 }, { 49.34737, -0.98946 }, { 49.77634, -1.93349 }, { 48.64442, -1.61651 }, { 48.90169, -3.29581 }, { 48.68416, -4.59234 }, { 47.95495, -4.49155 }, { 47.57032, -2.96327 }, { 46.01491, -1.19379 }, { 44.02261, -1.38422 }, { 43.42280, -1.90135 }, { 43.03401, -1.50277 }, { 42.34338, 1.82679 }, { 42.47301, 2.98599 }, { 43.07520, 3.10041 }, { 43.39965, 4.55696 }, { 43.12889, 6.52924 }, { 43.69384, 7.43518 }, { 44.12790, 7.54959 }, { 45.02851, 6.74995 }, { 45.33309, 7.09665 }, { 46.42967, 6.50009 }, { 46.27298, 6.02260 }, { 46.72577, 6.03738 }, { 47.62058, 7.46675 }, { 49.01778, 8.09927 }, { 49.20195, 6.65822 }, { 49.44266, 5.89775 }, { 49.98537, 4.79922 } });
final SphericalPolygonsSet corsica = buildSimpleZone(new double[][] { { 42.15249, 9.56001 }, { 43.00998, 9.39000 }, { 42.62812, 8.74600 }, { 42.25651, 8.54421 }, { 41.58361, 8.77572 }, { 41.38000, 9.22975 } });
return (SphericalPolygonsSet) new RegionFactory<Sphere2D>().union(continental, corsica);
}
Aggregations