Search in sources :

Example 21 with Rotation

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

the class AngularCoordinatesTest method testSpin.

@Test
public void testSpin() throws OrekitException {
    double rate = 2 * FastMath.PI / (12 * 60);
    AngularCoordinates angularCoordinates = new AngularCoordinates(new Rotation(0.48, 0.64, 0.36, 0.48, false), new Vector3D(rate, Vector3D.PLUS_K));
    Assert.assertEquals(rate, angularCoordinates.getRotationRate().getNorm(), 1.0e-10);
    double dt = 10.0;
    AngularCoordinates shifted = angularCoordinates.shiftedBy(dt);
    Assert.assertEquals(rate, shifted.getRotationRate().getNorm(), 1.0e-10);
    Assert.assertEquals(rate * dt, Rotation.distance(angularCoordinates.getRotation(), shifted.getRotation()), 1.0e-10);
    Vector3D shiftedX = shifted.getRotation().applyInverseTo(Vector3D.PLUS_I);
    Vector3D shiftedY = shifted.getRotation().applyInverseTo(Vector3D.PLUS_J);
    Vector3D shiftedZ = shifted.getRotation().applyInverseTo(Vector3D.PLUS_K);
    Vector3D originalX = angularCoordinates.getRotation().applyInverseTo(Vector3D.PLUS_I);
    Vector3D originalY = angularCoordinates.getRotation().applyInverseTo(Vector3D.PLUS_J);
    Vector3D originalZ = angularCoordinates.getRotation().applyInverseTo(Vector3D.PLUS_K);
    Assert.assertEquals(FastMath.cos(rate * dt), Vector3D.dotProduct(shiftedX, originalX), 1.0e-10);
    Assert.assertEquals(FastMath.sin(rate * dt), Vector3D.dotProduct(shiftedX, originalY), 1.0e-10);
    Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedX, originalZ), 1.0e-10);
    Assert.assertEquals(-FastMath.sin(rate * dt), Vector3D.dotProduct(shiftedY, originalX), 1.0e-10);
    Assert.assertEquals(FastMath.cos(rate * dt), Vector3D.dotProduct(shiftedY, originalY), 1.0e-10);
    Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedY, originalZ), 1.0e-10);
    Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedZ, originalX), 1.0e-10);
    Assert.assertEquals(0.0, Vector3D.dotProduct(shiftedZ, originalY), 1.0e-10);
    Assert.assertEquals(1.0, Vector3D.dotProduct(shiftedZ, originalZ), 1.0e-10);
    Vector3D forward = AngularCoordinates.estimateRate(angularCoordinates.getRotation(), shifted.getRotation(), dt);
    Assert.assertEquals(0.0, forward.subtract(angularCoordinates.getRotationRate()).getNorm(), 1.0e-10);
    Vector3D reversed = AngularCoordinates.estimateRate(shifted.getRotation(), angularCoordinates.getRotation(), dt);
    Assert.assertEquals(0.0, reversed.add(angularCoordinates.getRotationRate()).getNorm(), 1.0e-10);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) Test(org.junit.Test)

Example 22 with Rotation

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

the class AngularCoordinatesTest method testDerivativesStructures0.

@Test
public void testDerivativesStructures0() throws OrekitException {
    RandomGenerator random = new Well1024a(0x18a0a08fd63f047al);
    Rotation r = randomRotation(random);
    Vector3D o = randomVector(random, 1.0e-2);
    Vector3D oDot = randomVector(random, 1.0e-2);
    AngularCoordinates ac = new AngularCoordinates(r, o, oDot);
    AngularCoordinates rebuilt = new AngularCoordinates(ac.toDerivativeStructureRotation(0));
    Assert.assertEquals(0.0, Rotation.distance(ac.getRotation(), rebuilt.getRotation()), 1.0e-15);
    Assert.assertEquals(0.0, rebuilt.getRotationRate().getNorm(), 1.0e-15);
    Assert.assertEquals(0.0, rebuilt.getRotationAcceleration().getNorm(), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 23 with Rotation

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

the class AngularCoordinatesTest method testRandomPVCoordinates.

@Test
public void testRandomPVCoordinates() throws OrekitException {
    RandomGenerator generator = new Well1024a(0x49eb5b92d1f94b89l);
    for (int i = 0; i < 100; ++i) {
        Rotation r = randomRotation(generator);
        Vector3D omega = randomVector(generator, 10 * generator.nextDouble() + 1.0);
        Vector3D omegaDot = randomVector(generator, 0.1 * generator.nextDouble() + 0.01);
        AngularCoordinates ref = new AngularCoordinates(r, omega, omegaDot);
        AngularCoordinates inv = ref.revert();
        for (int j = 0; j < 100; ++j) {
            PVCoordinates v1 = randomPVCoordinates(generator, 1000, 1.0, 0.001);
            PVCoordinates v2 = randomPVCoordinates(generator, 1000, 1.0, 0.0010);
            PVCoordinates u1 = inv.applyTo(v1);
            PVCoordinates u2 = inv.applyTo(v2);
            AngularCoordinates rebuilt = new AngularCoordinates(u1, u2, v1, v2, 1.0e-9);
            Assert.assertEquals(0.0, Rotation.distance(r, rebuilt.getRotation()), 4.0e-14);
            Assert.assertEquals(0.0, Vector3D.distance(omega, rebuilt.getRotationRate()), 3.0e-12 * omega.getNorm());
            Assert.assertEquals(0.0, Vector3D.distance(omegaDot, rebuilt.getRotationAcceleration()), 2.0e-6 * omegaDot.getNorm());
        }
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) RandomGenerator(org.hipparchus.random.RandomGenerator) Well1024a(org.hipparchus.random.Well1024a) Test(org.junit.Test)

Example 24 with Rotation

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

the class AlongTrackAiming method alongTileDirection.

/**
 * {@inheritDoc}
 */
@Override
public Vector3D alongTileDirection(final Vector3D point, final GeodeticPoint gp) throws OrekitException {
    final double lStart = halfTrack.get(0).getFirst().getLatitude();
    final double lEnd = halfTrack.get(halfTrack.size() - 1).getFirst().getLatitude();
    // check the point can be reached
    if (gp.getLatitude() < FastMath.min(lStart, lEnd) || gp.getLatitude() > FastMath.max(lStart, lEnd)) {
        throw new OrekitException(OrekitMessages.OUT_OF_RANGE_LATITUDE, FastMath.toDegrees(gp.getLatitude()), FastMath.toDegrees(FastMath.min(lStart, lEnd)), FastMath.toDegrees(FastMath.max(lStart, lEnd)));
    }
    // bracket the point in the half track sample
    int iInf = 0;
    int iSup = halfTrack.size() - 1;
    while (iSup - iInf > 1) {
        final int iMiddle = (iSup + iInf) / 2;
        if ((lStart < lEnd) ^ (halfTrack.get(iMiddle).getFirst().getLatitude() > gp.getLatitude())) {
            // the specified latitude is in the second half
            iInf = iMiddle;
        } else {
            // the specified latitude is in the first half
            iSup = iMiddle;
        }
    }
    // ensure we can get points at iStart, iStart + 1, iStart + 2 and iStart + 3
    final int iStart = FastMath.max(0, FastMath.min(iInf - 1, halfTrack.size() - 4));
    // interpolate ground sliding point at specified latitude
    final HermiteInterpolator interpolator = new HermiteInterpolator();
    for (int i = iStart; i < iStart + 4; ++i) {
        final Vector3D position = halfTrack.get(i).getSecond().getPosition();
        final Vector3D velocity = halfTrack.get(i).getSecond().getVelocity();
        interpolator.addSamplePoint(halfTrack.get(i).getFirst().getLatitude(), new double[] { position.getX(), position.getY(), position.getZ(), velocity.getX(), velocity.getY(), velocity.getZ() });
    }
    final DerivativeStructure[] p = interpolator.value(factory.variable(0, gp.getLatitude()));
    // extract interpolated ground position/velocity
    final Vector3D position = new Vector3D(p[0].getValue(), p[1].getValue(), p[2].getValue());
    final Vector3D velocity = new Vector3D(p[3].getValue(), p[4].getValue(), p[5].getValue());
    // adjust longitude to match the specified one
    final Rotation rotation = new Rotation(Vector3D.PLUS_K, position, Vector3D.PLUS_K, point);
    final Vector3D fixedVelocity = rotation.applyTo(velocity);
    // the tile direction is aligned with sliding point velocity
    return fixedVelocity.normalize();
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) OrekitException(org.orekit.errors.OrekitException) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) GeodeticPoint(org.orekit.bodies.GeodeticPoint) HermiteInterpolator(org.hipparchus.analysis.interpolation.HermiteInterpolator)

Example 25 with Rotation

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

the class TODProvider method getTransform.

/**
 * {@inheritDoc}
 */
@Override
public Transform getTransform(final AbsoluteDate date) throws OrekitException {
    // compute nutation angles
    final double[] angles = nutationFunction.value(date);
    // compute the mean obliquity of the ecliptic
    final double moe = obliquityFunction.value(date);
    double dpsi = angles[0];
    double deps = angles[1];
    if (eopHistory != null) {
        // apply the corrections for the nutation parameters
        final double[] correction = eopHistory.getEquinoxNutationCorrection(date);
        dpsi += correction[0];
        deps += correction[1];
    }
    // compute the true obliquity of the ecliptic
    final double toe = moe + deps;
    // complete nutation
    final Rotation nutation = new Rotation(RotationOrder.XZX, RotationConvention.FRAME_TRANSFORM, moe, -dpsi, -toe);
    // set up the transform from parent MOD
    return new Transform(date, nutation);
}
Also used : FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation)

Aggregations

Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)145 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)116 Test (org.junit.Test)100 AbsoluteDate (org.orekit.time.AbsoluteDate)55 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)53 FieldRotation (org.hipparchus.geometry.euclidean.threed.FieldRotation)43 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)38 PVCoordinates (org.orekit.utils.PVCoordinates)30 SpacecraftState (org.orekit.propagation.SpacecraftState)26 DateComponents (org.orekit.time.DateComponents)22 Frame (org.orekit.frames.Frame)21 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)21 RandomGenerator (org.hipparchus.random.RandomGenerator)19 Transform (org.orekit.frames.Transform)19 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)19 CircularOrbit (org.orekit.orbits.CircularOrbit)18 TimeComponents (org.orekit.time.TimeComponents)17 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)16 GeodeticPoint (org.orekit.bodies.GeodeticPoint)15 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)14