use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.
the class FieldTransformTest method doTestLineDouble.
private <T extends RealFieldElement<T>> void doTestLineDouble(Field<T> field) {
RandomGenerator random = new Well19937a(0x4a5ff67426c5731fl);
for (int i = 0; i < 100; ++i) {
FieldTransform<T> transform = randomTransform(field, random);
for (int j = 0; j < 20; ++j) {
Vector3D p0 = randomVector(field, 1.0e3, random).toVector3D();
Vector3D p1 = randomVector(field, 1.0e3, random).toVector3D();
Line l = new Line(p0, p1, 1.0e-10);
FieldLine<T> transformed = transform.transformLine(l);
for (int k = 0; k < 10; ++k) {
Vector3D p = l.pointAt(random.nextDouble() * 1.0e6);
Assert.assertEquals(0.0, transformed.distance(transform.transformPosition(p)).getReal(), 1.0e-9);
}
}
}
}
use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.
the class FootprintOverlapDetectorTest method checkEventPair.
private void checkEventPair(final LoggedEvent start, final LoggedEvent end, final double expectedStart, final double expectedDuration, final double spacecraftLatitude, final double spacecraftLongitude, final double fovCenterLatitude, final double fovCenterLongitude) throws OrekitException {
Assert.assertFalse(start.isIncreasing());
Assert.assertTrue(end.isIncreasing());
Assert.assertEquals(expectedStart, start.getState().getDate().durationFrom(initialOrbit.getDate()), 0.001);
Assert.assertEquals(expectedDuration, end.getState().getDate().durationFrom(start.getState().getDate()), 0.001);
SpacecraftState middle = start.getState().shiftedBy(0.5 * expectedDuration);
// sub-satellite point
Vector3D p = middle.getPVCoordinates().getPosition();
GeodeticPoint gpSat = earth.transform(p, middle.getFrame(), middle.getDate());
Assert.assertEquals(spacecraftLatitude, FastMath.toDegrees(gpSat.getLatitude()), 0.001);
Assert.assertEquals(spacecraftLongitude, FastMath.toDegrees(gpSat.getLongitude()), 0.001);
// point at center of Field Of View
final Transform scToInert = middle.toTransform().getInverse();
GeodeticPoint gpFOV = earth.getIntersectionPoint(new Line(p, scToInert.transformPosition(Vector3D.PLUS_K), 1.0e-6), middle.getPVCoordinates().getPosition(), middle.getFrame(), middle.getDate());
Assert.assertEquals(fovCenterLatitude, FastMath.toDegrees(gpFOV.getLatitude()), 0.001);
Assert.assertEquals(fovCenterLongitude, FastMath.toDegrees(gpFOV.getLongitude()), 0.001);
}
use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.
the class BodyCenterPointingTest method testBodyCenterInPointingDirection.
/**
* Test if body center belongs to the direction pointed by the satellite
*/
@Test
public void testBodyCenterInPointingDirection() throws OrekitException {
// Transform satellite position to position/velocity parameters in EME2000 frame
PVCoordinates pvSatEME2000 = circ.getPVCoordinates();
// Pointing direction
// ********************
// Get satellite attitude rotation, i.e rotation from EME2000 frame to satellite frame
Rotation rotSatEME2000 = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
// Transform Z axis from satellite frame to EME2000
Vector3D zSatEME2000 = rotSatEME2000.applyInverseTo(Vector3D.PLUS_K);
// Transform Z axis from EME2000 to ITRF2008
Vector3D zSatITRF2008C = eme2000ToItrf.transformVector(zSatEME2000);
// Transform satellite position/velocity from EME2000 to ITRF2008
PVCoordinates pvSatITRF2008C = eme2000ToItrf.transformPVCoordinates(pvSatEME2000);
// Line containing satellite point and following pointing direction
Line pointingLine = new Line(pvSatITRF2008C.getPosition(), pvSatITRF2008C.getPosition().add(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, zSatITRF2008C), 2.0e-8);
// Check that the line contains Earth center
Assert.assertTrue(pointingLine.contains(Vector3D.ZERO));
}
use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.
the class OneAxisEllipsoidTest method testIntersectionFromPoints.
@Test
public void testIntersectionFromPoints() throws OrekitException {
AbsoluteDate date = new AbsoluteDate(new DateComponents(2008, 03, 21), TimeComponents.H12, TimeScalesFactory.getUTC());
Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
OneAxisEllipsoid earth = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, frame);
// Satellite on polar position
// ***************************
final double mu = 3.9860047e14;
CircularOrbit circ = new CircularOrbit(7178000.0, 0.5e-4, 0., FastMath.toRadians(90.), FastMath.toRadians(60.), FastMath.toRadians(90.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
// Transform satellite position to position/velocity parameters in EME2000 and ITRF200B
PVCoordinates pvSatEME2000 = circ.getPVCoordinates();
PVCoordinates pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000);
Vector3D pSatItrf = pvSatItrf.getPosition();
// Test first visible surface points
GeodeticPoint geoPoint = new GeodeticPoint(FastMath.toRadians(70.), FastMath.toRadians(60.), 0.);
Vector3D pointItrf = earth.transform(geoPoint);
Line line = new Line(pSatItrf, pointItrf, 1.0e-10);
GeodeticPoint geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
// Test second visible surface points
geoPoint = new GeodeticPoint(FastMath.toRadians(65.), FastMath.toRadians(-120.), 0.);
pointItrf = earth.transform(geoPoint);
line = new Line(pSatItrf, pointItrf, 1.0e-10);
geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
// Test non visible surface points
geoPoint = new GeodeticPoint(FastMath.toRadians(30.), FastMath.toRadians(60.), 0.);
pointItrf = earth.transform(geoPoint);
line = new Line(pSatItrf, pointItrf, 1.0e-10);
geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
// For polar satellite position, intersection point is at the same longitude but different latitude
Assert.assertEquals(1.04437199, geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(1.36198012, geoInter.getLatitude(), Utils.epsilonAngle);
// Satellite on equatorial position
// ********************************
circ = new CircularOrbit(7178000.0, 0.5e-4, 0., FastMath.toRadians(1.e-4), FastMath.toRadians(0.), FastMath.toRadians(0.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
// Transform satellite position to position/velocity parameters in EME2000 and ITRF200B
pvSatEME2000 = circ.getPVCoordinates();
pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000);
pSatItrf = pvSatItrf.getPosition();
// Test first visible surface points
geoPoint = new GeodeticPoint(FastMath.toRadians(5.), FastMath.toRadians(0.), 0.);
pointItrf = earth.transform(geoPoint);
line = new Line(pSatItrf, pointItrf, 1.0e-10);
Assert.assertTrue(line.toSubSpace(pSatItrf).getX() < 0);
geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
// With the point opposite to satellite point along the line
GeodeticPoint geoInter2 = earth.getIntersectionPoint(line, line.toSpace(new Vector1D(-line.toSubSpace(pSatItrf).getX())), frame, date);
Assert.assertTrue(FastMath.abs(geoInter.getLongitude() - geoInter2.getLongitude()) > FastMath.toRadians(0.1));
Assert.assertTrue(FastMath.abs(geoInter.getLatitude() - geoInter2.getLatitude()) > FastMath.toRadians(0.1));
// Test second visible surface points
geoPoint = new GeodeticPoint(FastMath.toRadians(-5.), FastMath.toRadians(0.), 0.);
pointItrf = earth.transform(geoPoint);
line = new Line(pSatItrf, pointItrf, 1.0e-10);
geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
// Test non visible surface points
geoPoint = new GeodeticPoint(FastMath.toRadians(40.), FastMath.toRadians(0.), 0.);
pointItrf = earth.transform(geoPoint);
line = new Line(pSatItrf, pointItrf, 1.0e-10);
geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
Assert.assertEquals(-0.00768481, geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(0.32180410, geoInter.getLatitude(), Utils.epsilonAngle);
// Satellite on any position
// *************************
circ = new CircularOrbit(7178000.0, 0.5e-4, 0., FastMath.toRadians(50.), FastMath.toRadians(0.), FastMath.toRadians(90.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
// Transform satellite position to position/velocity parameters in EME2000 and ITRF200B
pvSatEME2000 = circ.getPVCoordinates();
pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000);
pSatItrf = pvSatItrf.getPosition();
// Test first visible surface points
geoPoint = new GeodeticPoint(FastMath.toRadians(40.), FastMath.toRadians(90.), 0.);
pointItrf = earth.transform(geoPoint);
line = new Line(pSatItrf, pointItrf, 1.0e-10);
geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
// Test second visible surface points
geoPoint = new GeodeticPoint(FastMath.toRadians(60.), FastMath.toRadians(90.), 0.);
pointItrf = earth.transform(geoPoint);
line = new Line(pSatItrf, pointItrf, 1.0e-10);
geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle);
// Test non visible surface points
geoPoint = new GeodeticPoint(FastMath.toRadians(0.), FastMath.toRadians(90.), 0.);
pointItrf = earth.transform(geoPoint);
line = new Line(pSatItrf, pointItrf, 1.0e-10);
geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date);
Assert.assertEquals(FastMath.toRadians(89.5364061088196), geoInter.getLongitude(), Utils.epsilonAngle);
Assert.assertEquals(FastMath.toRadians(35.555543683351125), geoInter.getLatitude(), Utils.epsilonAngle);
}
use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.
the class OneAxisEllipsoidTest method testNoLineIntersection.
@Test
public void testNoLineIntersection() throws OrekitException {
AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
OneAxisEllipsoid model = new OneAxisEllipsoid(100.0, 0.9, frame);
Vector3D point = new Vector3D(0.0, 93.7139699, 3.5930796);
Vector3D direction = new Vector3D(0.0, 9.0, -2.0);
Line line = new Line(point, point.add(direction), 1.0e-10);
Assert.assertNull(model.getIntersectionPoint(line, point, frame, date));
}
Aggregations