Search in sources :

Example 16 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class FieldGeodeticPointTest method testGeodeticPoint.

/**
 * check {@link FieldGeodeticPoint#GeodeticPoint(RealFieldElement, RealFieldElement, RealFieldElement)} for
 * several different angles.
 */
@Test
public void testGeodeticPoint() {
    // setup
    // the input and expected results
    final double pi = FastMath.PI;
    double[][] points = { // first quadrant
    { pi / 6, pi / 6, pi / 6, pi / 6 }, // second quadrant
    { 4 * pi / 6, 4 * pi / 6, pi / 3, -pi / 3 }, // third quadrant
    { 7 * pi / 6, 7 * pi / 6, -pi / 6, pi / 6 }, // fourth quadrant
    { -pi / 6, -pi / 6, -pi / 6, -pi / 6 }, { -4 * pi / 6, -4 * pi / 6, -pi / 3, pi / 3 }, { -pi / 6, -4 * pi / 3, -pi / 6, 2 * pi / 3 } };
    for (double[] point : points) {
        // action
        FieldGeodeticPoint<Decimal64> gp = new FieldGeodeticPoint<Decimal64>(new Decimal64(point[0]), new Decimal64(point[1]), Decimal64.ZERO);
        Assert.assertEquals(0, gp.getEast().crossProduct(gp.getNorth()).distance(gp.getZenith()).getReal(), 1.0e-15);
        Assert.assertEquals(0, gp.getNorth().crossProduct(gp.getWest()).distance(gp.getZenith()).getReal(), 1.0e-15);
        Assert.assertEquals(0, gp.getSouth().crossProduct(gp.getWest()).distance(gp.getNadir()).getReal(), 1.0e-15);
        Assert.assertEquals(0, gp.getEast().crossProduct(gp.getSouth()).distance(gp.getNadir()).getReal(), 1.0e-15);
        Assert.assertEquals(0, gp.getZenith().crossProduct(gp.getSouth()).distance(gp.getEast()).getReal(), 1.0e-15);
        Assert.assertEquals(0, gp.getNadir().crossProduct(gp.getWest()).distance(gp.getNorth()).getReal(), 1.0e-15);
        // verify to within 5 ulps
        Assert.assertEquals(point[2], gp.getLatitude().getReal(), 5 * FastMath.ulp(point[2]));
        Assert.assertEquals(point[3], gp.getLongitude().getReal(), 5 * FastMath.ulp(point[3]));
    }
}
Also used : Decimal64(org.hipparchus.util.Decimal64) Test(org.junit.Test)

Example 17 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class FieldGeodeticPointTest method testGeodeticPointAngleNormalization.

/**
 * check {@link FieldGeodeticPoint#GeodeticPoint(RealFieldElement, RealFieldElement, RealFieldElement)} angle
 * normalization.
 */
@Test
public void testGeodeticPointAngleNormalization() {
    // action
    FieldGeodeticPoint<Decimal64> point = new FieldGeodeticPoint<Decimal64>(new Decimal64(FastMath.toRadians(135)), new Decimal64(FastMath.toRadians(90 - 360)), new Decimal64(0));
    // verify
    Assert.assertEquals(FastMath.toRadians(45), point.getLatitude().getReal(), 1.0e-15);
    Assert.assertEquals(FastMath.toRadians(-90), point.getLongitude().getReal(), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(point.getEast().toVector3D(), Vector3D.PLUS_I), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(point.getNorth().toVector3D(), new Vector3D(0.50 * FastMath.PI, 0.25 * FastMath.PI)), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(point.getWest().toVector3D(), Vector3D.MINUS_I), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(point.getSouth().toVector3D(), new Vector3D(-0.50 * FastMath.PI, -0.25 * FastMath.PI)), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(point.getZenith().toVector3D(), new Vector3D(-0.50 * FastMath.PI, 0.25 * FastMath.PI)), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(point.getNadir().toVector3D(), new Vector3D(0.50 * FastMath.PI, -0.25 * FastMath.PI)), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Decimal64(org.hipparchus.util.Decimal64) Test(org.junit.Test)

Example 18 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class FieldGeodeticPointTest method testToString.

/**
 * check {@link FieldGeodeticPoint#toString()}.
 */
@Test
public void testToString() {
    // setup
    FieldGeodeticPoint<Decimal64> point = new FieldGeodeticPoint<Decimal64>(new Decimal64(FastMath.toRadians(30)), new Decimal64(FastMath.toRadians(60)), new Decimal64(90));
    // action
    String actual = point.toString();
    // verify
    Assert.assertEquals("{lat: 30 deg, lon: 60 deg, alt: 90}", actual);
}
Also used : Decimal64(org.hipparchus.util.Decimal64) Test(org.junit.Test)

Example 19 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class FieldGeodeticPointTest method testEquals.

/**
 * check {@link FieldGeodeticPoint#equals(Object)}.
 */
@Test
public void testEquals() {
    // setup
    FieldGeodeticPoint<Decimal64> point = new FieldGeodeticPoint<Decimal64>(new Decimal64(1), new Decimal64(2), new Decimal64(3));
    // actions + verify
    Assert.assertEquals(point, new FieldGeodeticPoint<Decimal64>(new Decimal64(1), new Decimal64(2), new Decimal64(3)));
    Assert.assertFalse(point.equals(new FieldGeodeticPoint<Decimal64>(new Decimal64(0), new Decimal64(2), new Decimal64(3))));
    Assert.assertFalse(point.equals(new FieldGeodeticPoint<Decimal64>(new Decimal64(1), new Decimal64(0), new Decimal64(3))));
    Assert.assertFalse(point.equals(new FieldGeodeticPoint<Decimal64>(new Decimal64(1), new Decimal64(2), new Decimal64(0))));
    Assert.assertFalse(point.equals(new Object()));
    Assert.assertEquals(point.hashCode(), new FieldGeodeticPoint<Decimal64>(new Decimal64(1), new Decimal64(2), new Decimal64(3)).hashCode());
    Assert.assertNotEquals(point.hashCode(), new FieldGeodeticPoint<Decimal64>(new Decimal64(1), new Decimal64(FastMath.nextUp(2)), new Decimal64(3)).hashCode());
}
Also used : Decimal64(org.hipparchus.util.Decimal64) Test(org.junit.Test)

Example 20 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class OneAxisEllipsoidTest method checkCartesianToEllipsoidic.

private void checkCartesianToEllipsoidic(double ae, double f, double x, double y, double z, double longitude, double latitude, double altitude) throws OrekitException {
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid model = new OneAxisEllipsoid(ae, f, frame);
    GeodeticPoint gp = model.transform(new Vector3D(x, y, z), frame, date);
    Assert.assertEquals(longitude, MathUtils.normalizeAngle(gp.getLongitude(), longitude), 1.0e-10);
    Assert.assertEquals(latitude, gp.getLatitude(), 1.0e-10);
    Assert.assertEquals(altitude, gp.getAltitude(), 1.0e-10 * FastMath.abs(ae));
    Vector3D rebuiltNadir = Vector3D.crossProduct(gp.getSouth(), gp.getWest());
    Assert.assertEquals(0, rebuiltNadir.subtract(gp.getNadir()).getNorm(), 1.0e-15);
    FieldGeodeticPoint<Decimal64> gp64 = model.transform(new FieldVector3D<Decimal64>(new Decimal64(x), new Decimal64(y), new Decimal64(z)), frame, new FieldAbsoluteDate<>(Decimal64Field.getInstance(), date));
    Assert.assertEquals(longitude, MathUtils.normalizeAngle(gp64.getLongitude().getReal(), longitude), 1.0e-10);
    Assert.assertEquals(latitude, gp64.getLatitude().getReal(), 1.0e-10);
    Assert.assertEquals(altitude, gp64.getAltitude().getReal(), 1.0e-10 * FastMath.abs(ae));
    FieldVector3D<Decimal64> rebuiltNadir64 = FieldVector3D.crossProduct(gp64.getSouth(), gp64.getWest());
    Assert.assertEquals(0, rebuiltNadir64.subtract(gp64.getNadir()).getNorm().getReal(), 1.0e-15);
}
Also used : Frame(org.orekit.frames.Frame) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Decimal64(org.hipparchus.util.Decimal64) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate)

Aggregations

Decimal64 (org.hipparchus.util.Decimal64)41 Test (org.junit.Test)37 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)21 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)18 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)12 FieldDerivativeStructure (org.hipparchus.analysis.differentiation.FieldDerivativeStructure)10 AbsoluteDate (org.orekit.time.AbsoluteDate)9 RandomGenerator (org.hipparchus.random.RandomGenerator)5 Well19937a (org.hipparchus.random.Well19937a)5 GeodeticPoint (org.orekit.bodies.GeodeticPoint)4 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)4 Frame (org.orekit.frames.Frame)4 FieldCartesianOrbit (org.orekit.orbits.FieldCartesianOrbit)3 TimeScale (org.orekit.time.TimeScale)3 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)3 PVCoordinates (org.orekit.utils.PVCoordinates)3 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)3 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)2 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)2 CelestialBody (org.orekit.bodies.CelestialBody)2