Example usage for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D

List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D.

Prototype

public Vector3D(double x, double y, double z) 

Source Link

Document

Simple constructor.

Usage

From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagatorTest.java

@Test(expected = PropagationException.class)
public void undergroundOrbit() throws OrekitException {

    // for a semi major axis < equatorial radius
    Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
    Vector3D velocity = new Vector3D(-500.0, 800.0, 100.0);
    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH;
    Orbit initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(),
            initDate, provider.getMu());
    // Extrapolator definition
    // -----------------------
    EcksteinHechlerPropagator extrapolator = new EcksteinHechlerPropagator(initialOrbit, provider);

    // Extrapolation at the initial date
    // ---------------------------------
    double delta_t = 0.0;
    AbsoluteDate extrapDate = initDate.shiftedBy(delta_t);
    extrapolator.propagate(extrapDate);/*from w w  w . j  a  va  2  s .  co m*/
}

From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagatorTest.java

@Test(expected = PropagationException.class)
public void criticalInclination() throws OrekitException {
    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH;
    Orbit initialOrbit = new CircularOrbit(
            new PVCoordinates(new Vector3D(-3862363.8474653554, -3521533.9758022362, 4647637.852558916),
                    new Vector3D(65.36170817232278, -6056.563439401233, -4511.1247889782757)),
            FramesFactory.getEME2000(), initDate, provider.getMu());

    // Extrapolator definition
    // -----------------------
    EcksteinHechlerPropagator extrapolator = new EcksteinHechlerPropagator(initialOrbit, provider);

    // Extrapolation at the initial date
    // ---------------------------------
    double delta_t = 0.0;
    AbsoluteDate extrapDate = initDate.shiftedBy(delta_t);
    extrapolator.propagate(extrapDate);/*from w  ww .  j a  va  2 s .c  o  m*/
}

From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagatorTest.java

@Test(expected = PropagationException.class)
public void tooEllipticalOrbit() throws OrekitException {
    // for an eccentricity too big for the model
    Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
    Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);
    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH;
    Orbit initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(),
            initDate, provider.getMu());
    // Extrapolator definition
    // -----------------------
    EcksteinHechlerPropagator extrapolator = new EcksteinHechlerPropagator(initialOrbit, provider);

    // Extrapolation at the initial date
    // ---------------------------------
    double delta_t = 0.0;
    AbsoluteDate extrapDate = initDate.shiftedBy(delta_t);
    extrapolator.propagate(extrapDate);//from ww w. j  ava 2  s.  c  om
}

From source file:org.orekit.propagation.analytical.KeplerianPropagatorTest.java

@Test
public void sameDateCartesian() throws OrekitException {

    // Definition of initial conditions with position and velocity
    //------------------------------------------------------------
    Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
    Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);

    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
    Orbit initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(),
            initDate, mu);/* w  w w .  ja v  a2 s .  c o m*/

    // Extrapolator definition
    // -----------------------
    KeplerianPropagator extrapolator = new KeplerianPropagator(initialOrbit);

    // Extrapolation at the initial date
    // ---------------------------------
    double delta_t = 0.0; // extrapolation duration in seconds
    AbsoluteDate extrapDate = initDate.shiftedBy(delta_t);

    SpacecraftState finalOrbit = extrapolator.propagate(extrapDate);

    double a = finalOrbit.getA();
    // another way to compute n
    double n = FastMath.sqrt(finalOrbit.getMu() / FastMath.pow(a, 3));

    Assert.assertEquals(n * delta_t, finalOrbit.getLM() - initialOrbit.getLM(),
            Utils.epsilonTest * FastMath.abs(n * delta_t));
    Assert.assertEquals(MathUtils.normalizeAngle(finalOrbit.getLM(), initialOrbit.getLM()),
            initialOrbit.getLM(), Utils.epsilonAngle * FastMath.abs(initialOrbit.getLM()));

    Assert.assertEquals(finalOrbit.getA(), initialOrbit.getA(), Utils.epsilonTest * initialOrbit.getA());
    Assert.assertEquals(finalOrbit.getE(), initialOrbit.getE(), Utils.epsilonE * initialOrbit.getE());
    Assert.assertEquals(MathUtils.normalizeAngle(finalOrbit.getI(), initialOrbit.getI()), initialOrbit.getI(),
            Utils.epsilonAngle * FastMath.abs(initialOrbit.getI()));

}

From source file:org.orekit.propagation.analytical.KeplerianPropagatorTest.java

@Test
public void propagatedCartesian() throws OrekitException {

    // Definition of initial conditions with position and velocity
    //------------------------------------------------------------
    Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
    Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);
    double mu = 3.9860047e14;

    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
    Orbit initialOrbit = new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(),
            initDate, mu);//from  w w w .  jav  a 2  s.  c om

    // Extrapolator definition
    // -----------------------
    KeplerianPropagator extrapolator = new KeplerianPropagator(initialOrbit);

    // Extrapolation at a final date different from initial date
    // ---------------------------------------------------------
    double delta_t = 100000.0; // extrapolation duration in seconds
    AbsoluteDate extrapDate = initDate.shiftedBy(delta_t);

    SpacecraftState finalOrbit = extrapolator.propagate(extrapDate);

    // computation of (M final - M initial) with another method
    double a = finalOrbit.getA();
    // another way to compute n
    double n = FastMath.sqrt(finalOrbit.getMu() / FastMath.pow(a, 3));

    Assert.assertEquals(n * delta_t, finalOrbit.getLM() - initialOrbit.getLM(), Utils.epsilonAngle);

    // computation of M final orbit
    double LM = finalOrbit.getLE() - finalOrbit.getEquinoctialEx() * FastMath.sin(finalOrbit.getLE())
            + finalOrbit.getEquinoctialEy() * FastMath.cos(finalOrbit.getLE());

    Assert.assertEquals(LM, finalOrbit.getLM(), Utils.epsilonAngle);

    // test of tan ((LE - Lv)/2) :
    Assert.assertEquals(FastMath.tan((finalOrbit.getLE() - finalOrbit.getLv()) / 2.),
            tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()),
            Utils.epsilonAngle);

    // test of evolution of M vs E: LM = LE - ex*sin(LE) + ey*cos(LE)
    // with ex and ey the same for initial and final orbit
    double deltaM = finalOrbit.getLM() - initialOrbit.getLM();
    double deltaE = finalOrbit.getLE() - initialOrbit.getLE();
    double delta = finalOrbit.getEquinoctialEx()
            * (FastMath.sin(finalOrbit.getLE()) - FastMath.sin(initialOrbit.getLE()))
            - finalOrbit.getEquinoctialEy()
                    * (FastMath.cos(finalOrbit.getLE()) - FastMath.cos(initialOrbit.getLE()));

    Assert.assertEquals(deltaM, deltaE - delta, Utils.epsilonAngle);

    // the orbital elements except for Mean/True/Eccentric latitude arguments are the same
    Assert.assertEquals(finalOrbit.getA(), initialOrbit.getA(), Utils.epsilonTest * initialOrbit.getA());
    Assert.assertEquals(finalOrbit.getEquinoctialEx(), initialOrbit.getEquinoctialEx(), Utils.epsilonE);
    Assert.assertEquals(finalOrbit.getEquinoctialEy(), initialOrbit.getEquinoctialEy(), Utils.epsilonE);
    Assert.assertEquals(finalOrbit.getHx(), initialOrbit.getHx(), Utils.epsilonAngle);
    Assert.assertEquals(finalOrbit.getHy(), initialOrbit.getHy(), Utils.epsilonAngle);

    // for final orbit
    double ex = finalOrbit.getEquinoctialEx();
    double ey = finalOrbit.getEquinoctialEy();
    double hx = finalOrbit.getHx();
    double hy = finalOrbit.getHy();
    double LE = finalOrbit.getLE();

    double ex2 = ex * ex;
    double ey2 = ey * ey;
    double hx2 = hx * hx;
    double hy2 = hy * hy;
    double h2p1 = 1. + hx2 + hy2;
    double beta = 1. / (1. + FastMath.sqrt(1. - ex2 - ey2));

    double x3 = -ex + (1. - beta * ey2) * FastMath.cos(LE) + beta * ex * ey * FastMath.sin(LE);
    double y3 = -ey + (1. - beta * ex2) * FastMath.sin(LE) + beta * ex * ey * FastMath.cos(LE);

    Vector3D U = new Vector3D((1. + hx2 - hy2) / h2p1, (2. * hx * hy) / h2p1, (-2. * hy) / h2p1);

    Vector3D V = new Vector3D((2. * hx * hy) / h2p1, (1. - hx2 + hy2) / h2p1, (2. * hx) / h2p1);

    Vector3D r = new Vector3D(finalOrbit.getA(), (new Vector3D(x3, U, y3, V)));

    Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm(), r.getNorm(),
            Utils.epsilonTest * r.getNorm());

}

From source file:org.orekit.propagation.analytical.KeplerianPropagatorTest.java

@Test
public void propagatedKeplerian() throws OrekitException {

    // Definition of initial conditions with keplerian parameters
    //-----------------------------------------------------------
    AbsoluteDate initDate = AbsoluteDate.J2000_EPOCH.shiftedBy(584.);
    Orbit initialOrbit = new KeplerianOrbit(7209668.0, 0.5e-4, 1.7, 2.1, 2.9, 6.2, PositionAngle.TRUE,
            FramesFactory.getEME2000(), initDate, mu);

    // Extrapolator definition
    // -----------------------
    KeplerianPropagator extrapolator = new KeplerianPropagator(initialOrbit);

    // Extrapolation at a final date different from initial date
    // ---------------------------------------------------------
    double delta_t = 100000.0; // extrapolation duration in seconds
    AbsoluteDate extrapDate = initDate.shiftedBy(delta_t);

    SpacecraftState finalOrbit = extrapolator.propagate(extrapDate);
    Assert.assertEquals(6092.3362422560844633, finalOrbit.getKeplerianPeriod(), 1.0e-12);
    Assert.assertEquals(0.001031326088602888358, finalOrbit.getKeplerianMeanMotion(), 1.0e-16);

    // computation of (M final - M initial) with another method
    double a = finalOrbit.getA();
    // another way to compute n
    double n = FastMath.sqrt(finalOrbit.getMu() / FastMath.pow(a, 3));

    Assert.assertEquals(n * delta_t, finalOrbit.getLM() - initialOrbit.getLM(), Utils.epsilonAngle);

    // computation of M final orbit
    double LM = finalOrbit.getLE() - finalOrbit.getEquinoctialEx() * FastMath.sin(finalOrbit.getLE())
            + finalOrbit.getEquinoctialEy() * FastMath.cos(finalOrbit.getLE());

    Assert.assertEquals(LM, finalOrbit.getLM(), Utils.epsilonAngle);

    // test of tan ((LE - Lv)/2) :
    Assert.assertEquals(FastMath.tan((finalOrbit.getLE() - finalOrbit.getLv()) / 2.),
            tangLEmLv(finalOrbit.getLv(), finalOrbit.getEquinoctialEx(), finalOrbit.getEquinoctialEy()),
            Utils.epsilonAngle);/* ww w .  ja  v  a2  s  . com*/

    // test of evolution of M vs E: LM = LE - ex*sin(LE) + ey*cos(LE)
    // with ex and ey the same for initial and final orbit
    double deltaM = finalOrbit.getLM() - initialOrbit.getLM();
    double deltaE = finalOrbit.getLE() - initialOrbit.getLE();
    double delta = finalOrbit.getEquinoctialEx()
            * (FastMath.sin(finalOrbit.getLE()) - FastMath.sin(initialOrbit.getLE()))
            - finalOrbit.getEquinoctialEy()
                    * (FastMath.cos(finalOrbit.getLE()) - FastMath.cos(initialOrbit.getLE()));

    Assert.assertEquals(deltaM, deltaE - delta, Utils.epsilonAngle);

    // the orbital elements except for Mean/True/Eccentric latitude arguments are the same
    Assert.assertEquals(finalOrbit.getA(), initialOrbit.getA(), Utils.epsilonTest * initialOrbit.getA());
    Assert.assertEquals(finalOrbit.getEquinoctialEx(), initialOrbit.getEquinoctialEx(), Utils.epsilonE);
    Assert.assertEquals(finalOrbit.getEquinoctialEy(), initialOrbit.getEquinoctialEy(), Utils.epsilonE);
    Assert.assertEquals(finalOrbit.getHx(), initialOrbit.getHx(), Utils.epsilonAngle);
    Assert.assertEquals(finalOrbit.getHy(), initialOrbit.getHy(), Utils.epsilonAngle);

    // for final orbit
    double ex = finalOrbit.getEquinoctialEx();
    double ey = finalOrbit.getEquinoctialEy();
    double hx = finalOrbit.getHx();
    double hy = finalOrbit.getHy();
    double LE = finalOrbit.getLE();

    double ex2 = ex * ex;
    double ey2 = ey * ey;
    double hx2 = hx * hx;
    double hy2 = hy * hy;
    double h2p1 = 1. + hx2 + hy2;
    double beta = 1. / (1. + FastMath.sqrt(1. - ex2 - ey2));

    double x3 = -ex + (1. - beta * ey2) * FastMath.cos(LE) + beta * ex * ey * FastMath.sin(LE);
    double y3 = -ey + (1. - beta * ex2) * FastMath.sin(LE) + beta * ex * ey * FastMath.cos(LE);

    Vector3D U = new Vector3D((1. + hx2 - hy2) / h2p1, (2. * hx * hy) / h2p1, (-2. * hy) / h2p1);

    Vector3D V = new Vector3D((2. * hx * hy) / h2p1, (1. - hx2 + hy2) / h2p1, (2. * hx) / h2p1);

    Vector3D r = new Vector3D(finalOrbit.getA(), (new Vector3D(x3, U, y3, V)));

    Assert.assertEquals(finalOrbit.getPVCoordinates().getPosition().getNorm(), r.getNorm(),
            Utils.epsilonTest * r.getNorm());

}

From source file:org.orekit.propagation.analytical.KeplerianPropagatorTest.java

@Test
public void testIssue107() throws OrekitException {
    final TimeScale utc = TimeScalesFactory.getUTC();
    final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
    final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
    final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    final Orbit orbit = new CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(),
            date, mu);// w w  w .j av  a2 s . co  m

    Propagator propagator = new KeplerianPropagator(orbit) {
        AbsoluteDate lastDate = AbsoluteDate.PAST_INFINITY;

        protected SpacecraftState basicPropagate(final AbsoluteDate date) throws PropagationException {
            if (date.compareTo(lastDate) < 0) {
                throw new PropagationException(LocalizedFormats.SIMPLE_MESSAGE,
                        "no backward propagation allowed");
            }
            lastDate = date;
            return super.basicPropagate(date);
        }
    };

    SpacecraftState finalState = propagator.propagate(date.shiftedBy(3600.0));
    Assert.assertEquals(3600.0, finalState.getDate().durationFrom(date), 1.0e-15);

}