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

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

Introduction

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

Prototype

Vector3D ZERO

To view the source code for org.apache.commons.math3.geometry.euclidean.threed Vector3D ZERO.

Click Source Link

Document

Null vector (coordinates: 0, 0, 0).

Usage

From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java

/** {@inheritDoc} */
public Vector3D radiationPressureAcceleration(final AbsoluteDate date, final Frame frame,
        final Vector3D position, final Rotation rotation, final double mass, final Vector3D flux)
        throws OrekitException {

    if (flux.getNormSq() < Precision.SAFE_MIN) {
        // null illumination (we are probably in umbra)
        return Vector3D.ZERO;
    }// w w w  .j a  v  a  2s  .  c  om

    // radiation flux in spacecraft frame
    final Vector3D fluxSat = rotation.applyTo(flux);

    // solar array contribution
    Vector3D normal = getNormal(date, frame, position, rotation);
    double dot = Vector3D.dotProduct(normal, fluxSat);
    if (dot > 0) {
        // the solar array is illuminated backward,
        // fix signs to compute contribution correctly
        dot = -dot;
        normal = normal.negate();
    }
    Vector3D force = facetRadiationAcceleration(normal, solarArrayArea, fluxSat, dot);

    // body facets contribution
    for (final Facet bodyFacet : facets) {
        normal = bodyFacet.getNormal();
        dot = Vector3D.dotProduct(normal, fluxSat);
        if (dot < 0) {
            // the facet intercepts the incoming flux
            force = force.add(facetRadiationAcceleration(normal, bodyFacet.getArea(), fluxSat, dot));
        }
    }

    // convert to inertial frame
    return rotation.applyInverseTo(new Vector3D(1.0 / mass, force));

}

From source file:org.orekit.forces.drag.HarrisPriester.java

/** Get the inertial velocity of atmosphere molecules.
 * <p>/*from   w  ww .j a  v  a  2s  . c om*/
 * Here the case is simplified : atmosphere is supposed to have a null velocity
 * in earth frame.
 * </p>
 * @param date current date
 * @param position current position
 * @param frame the frame in which is defined the position
 * @return velocity (m/s) (defined in the same frame as the position)
 * @exception OrekitException if some frame conversion cannot be performed
 */
public Vector3D getVelocity(final AbsoluteDate date, final Vector3D position, final Frame frame)
        throws OrekitException {
    final Transform bodyToFrame = earth.getBodyFrame().getTransformTo(frame, date);
    final Vector3D posInBody = bodyToFrame.getInverse().transformPosition(position);
    final PVCoordinates pvBody = new PVCoordinates(posInBody, Vector3D.ZERO);
    final PVCoordinates pvFrame = bodyToFrame.transformPVCoordinates(pvBody);
    return pvFrame.getVelocity();
}

From source file:org.orekit.forces.maneuvers.ImpulseManeuverTest.java

@Test
public void testInertialManeuver() throws OrekitException {
    final double mu = CelestialBodyFactory.getEarth().getGM();

    final double initialX = 7100e3;
    final double initialY = 0.0;
    final double initialZ = 1300e3;
    final double initialVx = 0;
    final double initialVy = 8000;
    final double initialVz = 1000;

    final Vector3D position = new Vector3D(initialX, initialY, initialZ);
    final Vector3D velocity = new Vector3D(initialVx, initialVy, initialVz);
    final AbsoluteDate epoch = new AbsoluteDate(2010, 1, 1, 0, 0, 0, TimeScalesFactory.getUTC());
    final TimeStampedPVCoordinates state = new TimeStampedPVCoordinates(epoch, position, velocity,
            Vector3D.ZERO);
    final Orbit initialOrbit = new CartesianOrbit(state, FramesFactory.getEME2000(), mu);

    final double totalPropagationTime = 0.00001;
    final double driftTimeInSec = totalPropagationTime / 2.0;
    final double deltaX = 0.01;
    final double deltaY = 0.02;
    final double deltaZ = 0.03;
    final double isp = 300;

    final Vector3D deltaV = new Vector3D(deltaX, deltaY, deltaZ);

    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit,
            new LofOffset(initialOrbit.getFrame(), LOFType.VNC));
    DateDetector dateDetector = new DateDetector(epoch.shiftedBy(driftTimeInSec));
    InertialProvider attitudeOverride = new InertialProvider(new Rotation(RotationOrder.XYX, 0, 0, 0));
    ImpulseManeuver<DateDetector> burnAtEpoch = new ImpulseManeuver<DateDetector>(dateDetector,
            attitudeOverride, deltaV, isp).withThreshold(driftTimeInSec / 4);
    propagator.addEventDetector(burnAtEpoch);

    SpacecraftState finalState = propagator.propagate(epoch.shiftedBy(totalPropagationTime));

    final double finalVxExpected = initialVx + deltaX;
    final double finalVyExpected = initialVy + deltaY;
    final double finalVzExpected = initialVz + deltaZ;
    final double maneuverTolerance = 1e-4;

    final Vector3D finalVelocity = finalState.getPVCoordinates().getVelocity();
    Assert.assertEquals(finalVxExpected, finalVelocity.getX(), maneuverTolerance);
    Assert.assertEquals(finalVyExpected, finalVelocity.getY(), maneuverTolerance);
    Assert.assertEquals(finalVzExpected, finalVelocity.getZ(), maneuverTolerance);

}

From source file:org.orekit.forces.maneuvers.SmallManeuverAnalyticalModelTest.java

@Test
public void testLowEarthOrbit1() throws OrekitException {

    Orbit leo = new CircularOrbit(
            7200000.0, -1.0e-5, 2.0e-4, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.0,
            PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2004, 01, 01),
                    new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()),
            Constants.EIGEN5C_EARTH_MU);
    double mass = 5600.0;
    AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0);
    Vector3D dV = new Vector3D(-0.01, 0.02, 0.03);
    double f = 20.0;
    double isp = 315.0;
    BoundedPropagator withoutManeuver = getEphemeris(leo, mass, t0, Vector3D.ZERO, f, isp);
    BoundedPropagator withManeuver = getEphemeris(leo, mass, t0, dV, f, isp);
    SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0), dV,
            isp);/*from w  ww  .j av a2s.  c  o  m*/
    Assert.assertEquals(t0, model.getDate());

    for (AbsoluteDate t = withoutManeuver.getMinDate(); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t
            .shiftedBy(60.0)) {
        PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, leo.getFrame());
        PVCoordinates pvWith = withManeuver.getPVCoordinates(t, leo.getFrame());
        PVCoordinates pvModel = model.apply(withoutManeuver.propagate(t)).getPVCoordinates(leo.getFrame());
        double nominalDeltaP = new PVCoordinates(pvWith, pvWithout).getPosition().getNorm();
        double modelError = new PVCoordinates(pvWith, pvModel).getPosition().getNorm();
        if (t.compareTo(t0) < 0) {
            // before maneuver, all positions should be equal
            Assert.assertEquals(0, nominalDeltaP, 1.0e-10);
            Assert.assertEquals(0, modelError, 1.0e-10);
        } else {
            // after maneuver, model error should be less than 0.8m,
            // despite nominal deltaP exceeds 1 kilometer after less than 3 orbits
            if (t.durationFrom(t0) > 0.1 * leo.getKeplerianPeriod()) {
                Assert.assertTrue(modelError < 0.009 * nominalDeltaP);
            }
            Assert.assertTrue(modelError < 0.8);
        }
    }

}

From source file:org.orekit.forces.maneuvers.SmallManeuverAnalyticalModelTest.java

@Test
public void testLowEarthOrbit2() throws OrekitException {

    Orbit leo = new CircularOrbit(
            7200000.0, -1.0e-5, 2.0e-4, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.0,
            PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2004, 01, 01),
                    new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()),
            Constants.EIGEN5C_EARTH_MU);
    double mass = 5600.0;
    AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0);
    Vector3D dV = new Vector3D(-0.01, 0.02, 0.03);
    double f = 20.0;
    double isp = 315.0;
    BoundedPropagator withoutManeuver = getEphemeris(leo, mass, t0, Vector3D.ZERO, f, isp);
    BoundedPropagator withManeuver = getEphemeris(leo, mass, t0, dV, f, isp);
    SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0), dV,
            isp);// w  w  w  .j a  v a 2s  . co  m
    Assert.assertEquals(t0, model.getDate());

    for (AbsoluteDate t = withoutManeuver.getMinDate(); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t
            .shiftedBy(60.0)) {
        PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, leo.getFrame());
        PVCoordinates pvWith = withManeuver.getPVCoordinates(t, leo.getFrame());
        PVCoordinates pvModel = model.apply(withoutManeuver.propagate(t).getOrbit())
                .getPVCoordinates(leo.getFrame());
        double nominalDeltaP = new PVCoordinates(pvWith, pvWithout).getPosition().getNorm();
        double modelError = new PVCoordinates(pvWith, pvModel).getPosition().getNorm();
        if (t.compareTo(t0) < 0) {
            // before maneuver, all positions should be equal
            Assert.assertEquals(0, nominalDeltaP, 1.0e-10);
            Assert.assertEquals(0, modelError, 1.0e-10);
        } else {
            // after maneuver, model error should be less than 0.8m,
            // despite nominal deltaP exceeds 1 kilometer after less than 3 orbits
            if (t.durationFrom(t0) > 0.1 * leo.getKeplerianPeriod()) {
                Assert.assertTrue(modelError < 0.009 * nominalDeltaP);
            }
            Assert.assertTrue(modelError < 0.8);
        }
    }

}

From source file:org.orekit.forces.maneuvers.SmallManeuverAnalyticalModelTest.java

@Test
public void testEccentricOrbit() throws OrekitException {

    Orbit heo = new KeplerianOrbit(90000000.0, 0.92, FastMath.toRadians(98.0), FastMath.toRadians(12.3456),
            FastMath.toRadians(123.456), FastMath.toRadians(1.23456), PositionAngle.MEAN,
            FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2004, 01, 01),
                    new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()),
            Constants.EIGEN5C_EARTH_MU);
    double mass = 5600.0;
    AbsoluteDate t0 = heo.getDate().shiftedBy(1000.0);
    Vector3D dV = new Vector3D(-0.01, 0.02, 0.03);
    double f = 20.0;
    double isp = 315.0;
    BoundedPropagator withoutManeuver = getEphemeris(heo, mass, t0, Vector3D.ZERO, f, isp);
    BoundedPropagator withManeuver = getEphemeris(heo, mass, t0, dV, f, isp);
    SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(withoutManeuver.propagate(t0), dV,
            isp);/*  w  w w.  ja  v  a2 s  .  co  m*/
    Assert.assertEquals(t0, model.getDate());

    for (AbsoluteDate t = withoutManeuver.getMinDate(); t.compareTo(withoutManeuver.getMaxDate()) < 0; t = t
            .shiftedBy(600.0)) {
        PVCoordinates pvWithout = withoutManeuver.getPVCoordinates(t, heo.getFrame());
        PVCoordinates pvWith = withManeuver.getPVCoordinates(t, heo.getFrame());
        PVCoordinates pvModel = model.apply(withoutManeuver.propagate(t)).getPVCoordinates(heo.getFrame());
        double nominalDeltaP = new PVCoordinates(pvWith, pvWithout).getPosition().getNorm();
        double modelError = new PVCoordinates(pvWith, pvModel).getPosition().getNorm();
        if (t.compareTo(t0) < 0) {
            // before maneuver, all positions should be equal
            Assert.assertEquals(0, nominalDeltaP, 1.0e-10);
            Assert.assertEquals(0, modelError, 1.0e-10);
        } else {
            // after maneuver, model error should be less than 1700m,
            // despite nominal deltaP exceeds 300 kilometers at perigee, after 3 orbits
            if (t.durationFrom(t0) > 0.01 * heo.getKeplerianPeriod()) {
                Assert.assertTrue(modelError < 0.005 * nominalDeltaP);
            }
            Assert.assertTrue(modelError < 1700);
        }
    }

}

From source file:org.orekit.forces.maneuvers.SmallManeuverAnalyticalModelTest.java

@Test
public void testJacobian() throws OrekitException {

    Frame eme2000 = FramesFactory.getEME2000();
    Orbit leo = new CircularOrbit(
            7200000.0, -1.0e-2, 2.0e-3, FastMath.toRadians(98.0), FastMath.toRadians(123.456), 0.3,
            PositionAngle.MEAN, eme2000, new AbsoluteDate(new DateComponents(2004, 01, 01),
                    new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC()),
            Constants.EIGEN5C_EARTH_MU);
    double mass = 5600.0;
    AbsoluteDate t0 = leo.getDate().shiftedBy(1000.0);
    Vector3D dV0 = new Vector3D(-0.1, 0.2, 0.3);
    double f = 400.0;
    double isp = 315.0;

    for (OrbitType orbitType : OrbitType.values()) {
        for (PositionAngle positionAngle : PositionAngle.values()) {
            BoundedPropagator withoutManeuver = getEphemeris(orbitType.convertType(leo), mass, t0,
                    Vector3D.ZERO, f, isp);

            SpacecraftState state0 = withoutManeuver.propagate(t0);
            SmallManeuverAnalyticalModel model = new SmallManeuverAnalyticalModel(state0, eme2000, dV0, isp);
            Assert.assertEquals(t0, model.getDate());

            Vector3D[] velDirs = new Vector3D[] { Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K,
                    Vector3D.ZERO };
            double[] timeDirs = new double[] { 0, 0, 0, 1 };
            double h = 1.0;
            AbsoluteDate t1 = t0.shiftedBy(20.0);
            for (int i = 0; i < 4; ++i) {

                SmallManeuverAnalyticalModel[] models = new SmallManeuverAnalyticalModel[] {
                        new SmallManeuverAnalyticalModel(
                                withoutManeuver.propagate(t0.shiftedBy(-4 * h * timeDirs[i])), eme2000,
                                new Vector3D(1, dV0, -4 * h, velDirs[i]), isp),
                        new SmallManeuverAnalyticalModel(
                                withoutManeuver.propagate(t0.shiftedBy(-3 * h * timeDirs[i])), eme2000,
                                new Vector3D(1, dV0, -3 * h, velDirs[i]), isp),
                        new SmallManeuverAnalyticalModel(
                                withoutManeuver.propagate(t0.shiftedBy(-2 * h * timeDirs[i])), eme2000,
                                new Vector3D(1, dV0, -2 * h, velDirs[i]), isp),
                        new SmallManeuverAnalyticalModel(
                                withoutManeuver.propagate(t0.shiftedBy(-1 * h * timeDirs[i])), eme2000,
                                new Vector3D(1, dV0, -1 * h, velDirs[i]), isp),
                        new SmallManeuverAnalyticalModel(
                                withoutManeuver.propagate(t0.shiftedBy(+1 * h * timeDirs[i])), eme2000,
                                new Vector3D(1, dV0, +1 * h, velDirs[i]), isp),
                        new SmallManeuverAnalyticalModel(
                                withoutManeuver.propagate(t0.shiftedBy(+2 * h * timeDirs[i])), eme2000,
                                new Vector3D(1, dV0, +2 * h, velDirs[i]), isp),
                        new SmallManeuverAnalyticalModel(
                                withoutManeuver.propagate(t0.shiftedBy(+3 * h * timeDirs[i])), eme2000,
                                new Vector3D(1, dV0, +3 * h, velDirs[i]), isp),
                        new SmallManeuverAnalyticalModel(
                                withoutManeuver.propagate(t0.shiftedBy(+4 * h * timeDirs[i])), eme2000,
                                new Vector3D(1, dV0, +4 * h, velDirs[i]), isp), };
                double[][] array = new double[models.length][6];

                Orbit orbitWithout = withoutManeuver.propagate(t1).getOrbit();

                // compute reference orbit gradient by finite differences
                double c = 1.0 / (840 * h);
                for (int j = 0; j < models.length; ++j) {
                    orbitType.mapOrbitToArray(models[j].apply(orbitWithout), positionAngle, array[j]);
                }/*from  w  w w.j a  v a 2 s  . c o m*/
                double[] orbitGradient = new double[6];
                for (int k = 0; k < orbitGradient.length; ++k) {
                    double d4 = array[7][k] - array[0][k];
                    double d3 = array[6][k] - array[1][k];
                    double d2 = array[5][k] - array[2][k];
                    double d1 = array[4][k] - array[3][k];
                    orbitGradient[k] = (-3 * d4 + 32 * d3 - 168 * d2 + 672 * d1) * c;
                }

                // analytical Jacobian to check
                double[][] jacobian = new double[6][4];
                model.getJacobian(orbitWithout, positionAngle, jacobian);

                for (int j = 0; j < orbitGradient.length; ++j) {
                    Assert.assertEquals(orbitGradient[j], jacobian[j][i],
                            7.0e-6 * FastMath.abs(orbitGradient[j]));
                }

            }

        }

    }

}

From source file:org.orekit.frames.CIRFProvider.java

/** Get the transform from GCRF to CIRF2000 at the specified date.
 * <p>The transform considers the nutation and precession effects from IERS data.</p>
 * @param date new value of the date//from   w w w  .ja v  a 2 s  .  c om
 * @return transform at the specified date
 * @exception OrekitException if the nutation model data embedded in the
 * library cannot be read
 */
public Transform getTransform(final AbsoluteDate date) throws OrekitException {

    final double[] xys = xysPxy2Function.value(date);
    final double[] dxdy = eopHistory.getNonRotatinOriginNutationCorrection(date);

    // position of the Celestial Intermediate Pole (CIP)
    final double xCurrent = xys[0] + dxdy[0];
    final double yCurrent = xys[1] + dxdy[1];

    // position of the Celestial Intermediate Origin (CIO)
    final double sCurrent = xys[2] - xCurrent * yCurrent / 2;

    // set up the bias, precession and nutation rotation
    final double x2Py2 = xCurrent * xCurrent + yCurrent * yCurrent;
    final double zP1 = 1 + FastMath.sqrt(1 - x2Py2);
    final double r = FastMath.sqrt(x2Py2);
    final double sPe2 = 0.5 * (sCurrent + FastMath.atan2(yCurrent, xCurrent));
    final double cos = FastMath.cos(sPe2);
    final double sin = FastMath.sin(sPe2);
    final double xPr = xCurrent + r;
    final double xPrCos = xPr * cos;
    final double xPrSin = xPr * sin;
    final double yCos = yCurrent * cos;
    final double ySin = yCurrent * sin;
    final Rotation bpn = new Rotation(zP1 * (xPrCos + ySin), -r * (yCos + xPrSin), r * (xPrCos - ySin),
            zP1 * (yCos - xPrSin), true);

    return new Transform(date, bpn, Vector3D.ZERO);

}

From source file:org.orekit.frames.ITRFProvider.java

/** Get the transform from TIRF 2000 at specified date.
 * <p>The update considers the pole motion from IERS data.</p>
 * @param date new value of the date//from w  w  w . j  ava 2  s  .c  o  m
 * @return transform at the specified date
 * @exception OrekitException if the nutation model data embedded in the
 * library cannot be read
 */
public Transform getTransform(final AbsoluteDate date) throws OrekitException {

    // offset from J2000 epoch in julian centuries
    final double tts = date.durationFrom(AbsoluteDate.J2000_EPOCH);
    final double ttc = tts / Constants.JULIAN_CENTURY;

    // pole correction parameters
    final PoleCorrection eop = eopHistory.getPoleCorrection(date);

    // elementary rotations due to pole motion in terrestrial frame
    final Rotation r1 = new Rotation(Vector3D.PLUS_I, -eop.getYp());
    final Rotation r2 = new Rotation(Vector3D.PLUS_J, -eop.getXp());
    final Rotation r3 = new Rotation(Vector3D.PLUS_K, S_PRIME_RATE * ttc);

    // complete pole motion in terrestrial frame
    final Rotation wRot = r3.applyTo(r2.applyTo(r1));

    // combined effects
    final Rotation combined = wRot.revert();

    // set up the transform from parent TIRF
    return new Transform(date, combined, Vector3D.ZERO);

}

From source file:org.orekit.frames.ITRFProviderWithoutTidalEffectsTest.java

@Test
public void testRoughRotation() throws OrekitException {

    AbsoluteDate date1 = new AbsoluteDate(new DateComponents(2006, 02, 24), new TimeComponents(15, 38, 00),
            TimeScalesFactory.getUTC());
    Frame itrf2008 = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    Transform t0 = itrf2008.getTransformTo(FramesFactory.getEME2000(), date1);

    double dt = 10.0;
    AbsoluteDate date2 = date1.shiftedBy(dt);
    Transform t1 = itrf2008.getTransformTo(FramesFactory.getEME2000(), date2);
    Transform evolution = new Transform(date2, t0.getInverse(), t1);

    Vector3D p = new Vector3D(6000, 6000, 0);
    Assert.assertEquals(0.0, evolution.transformPosition(Vector3D.ZERO).getNorm(), 1.0e-15);
    Assert.assertEquals(0.0, evolution.transformVector(p).getZ(), 0.003);
    Assert.assertEquals(2 * FastMath.PI * dt / 86164,
            Vector3D.angle(t0.transformVector(p), t1.transformVector(p)), 1.0e-9);

}