Search in sources :

Example 16 with Line

use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.

the class BodyCenterPointingTest method doTestBodyCenterInPointingDirection.

private <T extends RealFieldElement<T>> void doTestBodyCenterInPointingDirection(final Field<T> field) throws OrekitException {
    double mu = 3.9860047e14;
    T zero = field.getZero();
    // Satellite position as circular parameters
    final T raan = zero.add(FastMath.toRadians(270.));
    final T a = zero.add(7178000.0);
    final T e = zero.add(7E-5);
    final T i = zero.add(FastMath.toRadians(50.));
    final T pa = zero.add(FastMath.toRadians(45.));
    final T m = zero.add(FastMath.toRadians(5.300 - 270.));
    // Computation date
    FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getUTC());
    // Orbit
    FieldKeplerianOrbit<T> circ = new FieldKeplerianOrbit<>(a, e, i, pa, raan, m, PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
    // WGS84 Earth model
    OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    // Transform from EME2000 to ITRF2008
    Transform eme2000ToItrf = FramesFactory.getEME2000().getTransformTo(earth.getBodyFrame(), date.toAbsoluteDate());
    // Earth center pointing attitude provider
    BodyCenterPointing earthCenterAttitudeLaw = new BodyCenterPointing(circ.getFrame(), earth);
    // Transform satellite position to position/velocity parameters in EME2000 frame
    FieldPVCoordinates<T> pvSatEME2000 = circ.getPVCoordinates();
    // Pointing direction
    // ********************
    // Get satellite attitude rotation, i.e rotation from EME2000 frame to satellite frame
    FieldRotation<T> rotSatEME2000 = earthCenterAttitudeLaw.getAttitude(circ, date, circ.getFrame()).getRotation();
    // checked this values with the bodycenterpointing test values
    // Transform Z axis from satellite frame to EME2000
    FieldVector3D<T> zSatEME2000 = rotSatEME2000.applyInverseTo(Vector3D.PLUS_K);
    // Transform Z axis from EME2000 to ITRF2008
    FieldVector3D<T> zSatITRF2008C = eme2000ToItrf.transformVector(zSatEME2000);
    // Transform satellite position/velocity from EME2000 to ITRF2008
    FieldPVCoordinates<T> pvSatITRF2008C = eme2000ToItrf.transformPVCoordinates(pvSatEME2000);
    // Line containing satellite point and following pointing direction
    Line pointingLine = new Line(pvSatITRF2008C.getPosition().toVector3D(), pvSatITRF2008C.getPosition().toVector3D().add(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, zSatITRF2008C.toVector3D()), 2.0e-8);
    // Check that the line contains Earth center
    Assert.assertTrue(pointingLine.contains(Vector3D.ZERO));
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) DateComponents(org.orekit.time.DateComponents) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) Line(org.hipparchus.geometry.euclidean.threed.Line) Transform(org.orekit.frames.Transform) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 17 with Line

use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.

the class TransformTest method testIdentityLine.

@Test
public void testIdentityLine() {
    RandomGenerator random = new Well19937a(0x98603025df70db7cl);
    Vector3D p1 = randomVector(100.0, random);
    Vector3D p2 = randomVector(100.0, random);
    Line line = new Line(p1, p2, 1.0e-6);
    Line transformed = Transform.IDENTITY.transformLine(line);
    Assert.assertSame(line, transformed);
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Well19937a(org.hipparchus.random.Well19937a) RandomGenerator(org.hipparchus.random.RandomGenerator) Test(org.junit.Test)

Example 18 with Line

use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.

the class GeoidTest method testGetIntersectionPointNoIntersection.

/**
 * check {@link Geoid#getIntersectionPoint(Line, Vector3D, Frame,
 * AbsoluteDate)} returns null when there is no intersection
 *
 * @throws OrekitException on error
 */
@Test
public void testGetIntersectionPointNoIntersection() throws OrekitException {
    Geoid geoid = getComponent();
    Vector3D closeMiss = new Vector3D(geoid.getEllipsoid().getEquatorialRadius() + 18, 0, 0);
    Line line = new Line(closeMiss, closeMiss.add(Vector3D.PLUS_J), 0);
    // action
    final GeodeticPoint actual = geoid.getIntersectionPoint(line, closeMiss, geoid.getBodyFrame(), date);
    // verify
    assertThat(actual, nullValue());
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 19 with Line

use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.

the class GeoidTest method testGetIntersectionPoint.

/**
 * check {@link Geoid#getIntersectionPoint(Line, Vector3D, Frame,
 * AbsoluteDate)} with several points.
 *
 * @throws OrekitException on error
 */
@Test
public void testGetIntersectionPoint() throws OrekitException {
    // setup
    Geoid geoid = getComponent();
    Frame frame = geoid.getBodyFrame();
    for (double[] point : reference) {
        GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(point[0]), FastMath.toRadians(point[1]), 0);
        Vector3D expected = geoid.transform(gp);
        // glancing line: 10% vertical and 90% north (~6 deg elevation)
        Vector3D slope = gp.getZenith().scalarMultiply(0.1).add(gp.getNorth().scalarMultiply(0.9));
        Vector3D close = expected.add(slope.scalarMultiply(100e3));
        Vector3D pointOnLine = expected.add(slope);
        Line line = new Line(close, pointOnLine, 0);
        // line directed the other way
        Line otherDirection = new Line(pointOnLine, close, 0);
        // action
        GeodeticPoint actual = geoid.getIntersectionPoint(line, close, frame, date);
        // other direction
        GeodeticPoint actualReversed = geoid.getIntersectionPoint(otherDirection, close, frame, date);
        // verify
        String message = String.format("point: %s%n", Arrays.toString(point));
        // position accuracy on Earth's surface to 1.3 um.
        assertThat(message, actualReversed, geodeticPointCloseTo(gp, 1.3e-6));
        assertThat(message, actual, geodeticPointCloseTo(gp, 1.3e-6));
    }
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 20 with Line

use of org.hipparchus.geometry.euclidean.threed.Line in project Orekit by CS-SI.

the class GeoidTest method testGetIntersectionPointFrame.

/**
 * check {@link Geoid#getIntersectionPoint(Line, Vector3D, Frame,
 * AbsoluteDate)} handles frame transformations correctly
 *
 * @throws OrekitException on error
 */
@Test
public void testGetIntersectionPointFrame() throws OrekitException {
    // setup
    Geoid geoid = getComponent();
    Frame frame = new Frame(geoid.getBodyFrame(), new Transform(date, new Transform(date, new Vector3D(-1, 2, -3), new Vector3D(4, -5, 6)), new Transform(date, new Rotation(-7, 8, -9, 10, true), new Vector3D(-11, 12, -13))), "test frame");
    GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(46.8743190), FastMath.toRadians(102.4487290), 0);
    Vector3D expected = geoid.transform(gp);
    // glancing line: 10% vertical and 90% north (~6 deg elevation)
    Vector3D slope = gp.getZenith().scalarMultiply(0.1).add(gp.getNorth().scalarMultiply(0.9));
    Vector3D close = expected.add(slope.scalarMultiply(100));
    Line line = new Line(expected.add(slope), close, 0);
    Transform xform = geoid.getBodyFrame().getTransformTo(frame, date);
    // transform to test frame
    close = xform.transformPosition(close);
    line = xform.transformLine(line);
    // action
    GeodeticPoint actual = geoid.getIntersectionPoint(line, close, frame, date);
    // verify, 1 um position accuracy at Earth's surface
    assertThat(actual, geodeticPointCloseTo(gp, 1e-6));
}
Also used : Line(org.hipparchus.geometry.euclidean.threed.Line) Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Transform(org.orekit.frames.Transform) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) Test(org.junit.Test)

Aggregations

Line (org.hipparchus.geometry.euclidean.threed.Line)20 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)19 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)12 Test (org.junit.Test)11 GeodeticPoint (org.orekit.bodies.GeodeticPoint)10 Frame (org.orekit.frames.Frame)9 Transform (org.orekit.frames.Transform)6 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)6 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)6 FieldLine (org.hipparchus.geometry.euclidean.threed.FieldLine)5 AbsoluteDate (org.orekit.time.AbsoluteDate)5 OrekitException (org.orekit.errors.OrekitException)4 PVCoordinates (org.orekit.utils.PVCoordinates)4 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)3 RandomGenerator (org.hipparchus.random.RandomGenerator)3 Well19937a (org.hipparchus.random.Well19937a)3 FieldGeodeticPoint (org.orekit.bodies.FieldGeodeticPoint)3 FieldTransform (org.orekit.frames.FieldTransform)3 DateComponents (org.orekit.time.DateComponents)3 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)3