Search in sources :

Example 86 with Vector3D

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

the class Phasing method findLatitudeCrossing.

/**
 * Find the state at which the reference latitude is crossed.
 * @param latitude latitude to search for
 * @param guessDate guess date for the crossing
 * @param endDate maximal date not to overtake
 * @param shift shift value used to evaluate the latitude function bracketing around the guess date
 * @param maxShift maximum value that the shift value can take
 * @param propagator propagator used
 * @return state at latitude crossing time
 * @throws OrekitException if state cannot be propagated
 * @throws MathRuntimeException if latitude cannot be bracketed in the search interval
 */
private SpacecraftState findLatitudeCrossing(final double latitude, final AbsoluteDate guessDate, final AbsoluteDate endDate, final double shift, final double maxShift, final Propagator propagator) throws OrekitException, MathRuntimeException {
    // function evaluating to 0 at latitude crossings
    final UnivariateFunction latitudeFunction = new UnivariateFunction() {

        /**
         * {@inheritDoc}
         */
        public double value(double x) {
            try {
                final SpacecraftState state = propagator.propagate(guessDate.shiftedBy(x));
                final Vector3D position = state.getPVCoordinates(earth.getBodyFrame()).getPosition();
                final GeodeticPoint point = earth.transform(position, earth.getBodyFrame(), state.getDate());
                return point.getLatitude() - latitude;
            } catch (OrekitException oe) {
                throw new RuntimeException(oe);
            }
        }
    };
    // try to bracket the encounter
    double span;
    if (guessDate.shiftedBy(shift).compareTo(endDate) > 0) {
        // Take a 1e-3 security margin
        span = endDate.durationFrom(guessDate) - 1e-3;
    } else {
        span = shift;
    }
    while (!UnivariateSolverUtils.isBracketing(latitudeFunction, -span, span)) {
        if (2 * span > maxShift) {
            // let the Hipparchus exception be thrown
            UnivariateSolverUtils.verifyBracketing(latitudeFunction, -span, span);
        } else if (guessDate.shiftedBy(2 * span).compareTo(endDate) > 0) {
            // Out of range :
            return null;
        }
        // expand the search interval
        span *= 2;
    }
    // find the encounter in the bracketed interval
    final BaseUnivariateSolver<UnivariateFunction> solver = new BracketingNthOrderBrentSolver(0.1, 5);
    final double dt = solver.solve(1000, latitudeFunction, -span, span);
    return propagator.propagate(guessDate.shiftedBy(dt));
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint) BracketingNthOrderBrentSolver(org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver)

Example 87 with Vector3D

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

the class FieldAngularCoordinatesTest method testConversionConstructor.

@Test
public void testConversionConstructor() {
    AngularCoordinates ac = new AngularCoordinates(new Rotation(Vector3D.MINUS_J, 0.15, RotationConvention.VECTOR_OPERATOR), new Vector3D(0.001, 0.002, 0.003), new Vector3D(-1.0e-6, -3.0e-6, 7.0e-6));
    FieldAngularCoordinates<Decimal64> ac64 = new FieldAngularCoordinates<>(Decimal64Field.getInstance(), ac);
    Assert.assertEquals(0.0, Rotation.distance(ac.getRotation(), ac64.getRotation().toRotation()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(ac.getRotationRate(), ac64.getRotationRate().toVector3D()), 1.0e-15);
    Assert.assertEquals(0.0, Vector3D.distance(ac.getRotationAcceleration(), ac64.getRotationAcceleration().toVector3D()), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Decimal64(org.hipparchus.util.Decimal64) FieldRotation(org.hipparchus.geometry.euclidean.threed.FieldRotation) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) Test(org.junit.Test)

Example 88 with Vector3D

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

the class FieldAngularCoordinatesTest method testCancellingDerivatives.

@Test
public void testCancellingDerivatives() throws OrekitException {
    PVCoordinates u1 = new PVCoordinates(new Vector3D(-0.4466591282528639, -0.009657376949231283, -0.894652087807798), new Vector3D(-8.897296517803556E-4, 2.7825250920407674E-4, 4.411979658413134E-4), new Vector3D(4.753127475302486E-7, 1.0209400376727623E-8, 9.515403756524403E-7));
    PVCoordinates u2 = new PVCoordinates(new Vector3D(0.23723907259910096, 0.9628700806685033, -0.1288364474275361), new Vector3D(-7.98741002062555E-24, 2.4979687659429984E-24, 3.9607863426704016E-24), new Vector3D(-3.150541868418562E-23, 9.856329862034835E-24, 1.5648124883326986E-23));
    PVCoordinates v1 = new PVCoordinates(Vector3D.PLUS_K, Vector3D.ZERO, Vector3D.ZERO);
    PVCoordinates v2 = new PVCoordinates(Vector3D.MINUS_J, Vector3D.ZERO, Vector3D.ZERO);
    AngularCoordinates ac = new AngularCoordinates(u1, u2, v1, v2, 1.0e-9);
    PVCoordinates v1Computed = ac.applyTo(u1);
    PVCoordinates v2Computed = ac.applyTo(u2);
    Assert.assertEquals(0, Vector3D.distance(v1.getPosition(), v1Computed.getPosition()), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(v2.getPosition(), v2Computed.getPosition()), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(v1.getVelocity(), v1Computed.getVelocity()), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(v2.getVelocity(), v2Computed.getVelocity()), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(v1.getAcceleration(), v1Computed.getAcceleration()), 1.0e-15);
    Assert.assertEquals(0, Vector3D.distance(v2.getAcceleration(), v2Computed.getAcceleration()), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

Example 89 with Vector3D

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

the class PVCoordinatesTest method testGetMomentum.

@Test
public void testGetMomentum() {
    // setup
    Vector3D p = new Vector3D(1, -2, 3);
    Vector3D v = new Vector3D(-9, 8, -7);
    // action + verify
    Assert.assertEquals(new PVCoordinates(p, v).getMomentum(), p.crossProduct(v));
    // check simple cases
    Assert.assertEquals(new PVCoordinates(Vector3D.PLUS_I, Vector3D.MINUS_I).getMomentum(), Vector3D.ZERO);
    Assert.assertEquals(new PVCoordinates(Vector3D.PLUS_I, Vector3D.PLUS_J).getMomentum(), Vector3D.PLUS_K);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Test(org.junit.Test)

Example 90 with Vector3D

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

the class PVCoordinatesTest method testMomentumDerivative.

@Test
public void testMomentumDerivative() throws OrekitException {
    final PVCoordinates pva = new PVCoordinates(new Vector3D(-4947831., -3765382., -3708221.), new Vector3D(-2079., 5291., -7842.));
    final Vector3D p = pva.getPosition();
    final Vector3D v = pva.getVelocity();
    final Vector3D a = pva.getAcceleration();
    final double r2 = p.getNormSq();
    final double r = FastMath.sqrt(r2);
    final Vector3D keplerianJerk = new Vector3D(-3 * Vector3D.dotProduct(p, v) / r2, a, -a.getNorm() / r, v);
    final PVCoordinates velocity = new PVCoordinates(v, a, keplerianJerk);
    final Vector3D momentumRef = pva.getMomentum();
    final Vector3D momentumDotRef = PVCoordinates.crossProduct(pva, velocity).getVelocity();
    final FieldVector3D<DerivativeStructure> momentumDot = pva.toDerivativeStructurePV(1).getMomentum();
    Assert.assertEquals(momentumRef.getX(), momentumDot.getX().getReal(), 1.0e-15);
    Assert.assertEquals(momentumRef.getY(), momentumDot.getY().getReal(), 1.0e-15);
    Assert.assertEquals(momentumRef.getZ(), momentumDot.getZ().getReal(), 1.0e-15);
    Assert.assertEquals(momentumDotRef.getX(), momentumDot.getX().getPartialDerivative(1), 1.0e-15);
    Assert.assertEquals(momentumDotRef.getY(), momentumDot.getY().getPartialDerivative(1), 1.0e-15);
    Assert.assertEquals(momentumDotRef.getZ(), momentumDot.getZ().getPartialDerivative(1), 1.0e-15);
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) Test(org.junit.Test)

Aggregations

Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)750 Test (org.junit.Test)466 AbsoluteDate (org.orekit.time.AbsoluteDate)323 PVCoordinates (org.orekit.utils.PVCoordinates)280 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)259 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)187 SpacecraftState (org.orekit.propagation.SpacecraftState)152 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)124 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)119 Frame (org.orekit.frames.Frame)115 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)105 Orbit (org.orekit.orbits.Orbit)100 GeodeticPoint (org.orekit.bodies.GeodeticPoint)84 OrekitException (org.orekit.errors.OrekitException)83 CartesianOrbit (org.orekit.orbits.CartesianOrbit)75 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)68 DateComponents (org.orekit.time.DateComponents)67 Transform (org.orekit.frames.Transform)61 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)59 CircularOrbit (org.orekit.orbits.CircularOrbit)59