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.forces.gravity.HolmesFeatherstoneAttractionModelTest.java

@Test
public void testIssue97() throws OrekitException {

    Utils.setDataRoot("regular-data:potential/grgs-format");
    GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));

    // pos-vel (from a ZOOM ephemeris reference)
    final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06,
            -1.32931592294715829e+04);/*from  w ww  .  j av a  2  s .co m*/
    final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03,
            -1.14097953925384523e+01);
    final SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel),
            FramesFactory.getGCRF(), new AbsoluteDate(2005, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()),
            GravityFieldFactory.getUnnormalizedProvider(1, 1).getMu()));

    for (int i = 2; i <= 69; i++) {
        final ForceModel holmesFeatherstoneModel = new HolmesFeatherstoneAttractionModel(
                FramesFactory.getITRF(IERSConventions.IERS_2010, true),
                GravityFieldFactory.getNormalizedProvider(i, i));
        final ForceModel cunninghamModel = new CunninghamAttractionModel(
                FramesFactory.getITRF(IERSConventions.IERS_2010, true),
                GravityFieldFactory.getUnnormalizedProvider(i, i));
        double relativeError = accelerationRelativeError(holmesFeatherstoneModel, cunninghamModel, state);
        Assert.assertEquals(0.0, relativeError, 8.0e-15);
    }

}

From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModelTest.java

@Test
public void testParameterDerivative() throws OrekitException {

    Utils.setDataRoot("regular-data:potential/grgs-format");
    GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true));

    // pos-vel (from a ZOOM ephemeris reference)
    final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06,
            -1.32931592294715829e+04);// www. j  av  a 2s  .c  o  m
    final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03,
            -1.14097953925384523e+01);
    final SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel),
            FramesFactory.getGCRF(), new AbsoluteDate(2005, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()),
            GravityFieldFactory.getUnnormalizedProvider(1, 1).getMu()));

    final HolmesFeatherstoneAttractionModel holmesFeatherstoneModel = new HolmesFeatherstoneAttractionModel(
            FramesFactory.getITRF(IERSConventions.IERS_2010, true),
            GravityFieldFactory.getNormalizedProvider(20, 20));

    final String name = NewtonianAttraction.CENTRAL_ATTRACTION_COEFFICIENT;
    checkParameterDerivative(state, holmesFeatherstoneModel, name, 1.0e-5, 5.0e-12);

}

From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModelTest.java

@Test
public void testTimeDependentField() throws OrekitException {

    Utils.setDataRoot("regular-data:potential/icgem-format");
    GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("eigen-6s-truncated", true));

    final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06,
            -1.32931592294715829e+04);/*  w w w.j av  a2s . c o  m*/
    final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03,
            -1.14097953925384523e+01);
    final SpacecraftState spacecraftState = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel),
            FramesFactory.getGCRF(), new AbsoluteDate(2005, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()),
            GravityFieldFactory.getUnnormalizedProvider(1, 1).getMu()));

    double dP = 0.1;
    double duration = 3 * Constants.JULIAN_DAY;
    BoundedPropagator fixedFieldEphemeris = createEphemeris(dP, spacecraftState, duration,
            GravityFieldFactory.getConstantNormalizedProvider(8, 8));
    BoundedPropagator varyingFieldEphemeris = createEphemeris(dP, spacecraftState, duration,
            GravityFieldFactory.getNormalizedProvider(8, 8));

    double step = 60.0;
    double maxDeltaT = 0;
    double maxDeltaN = 0;
    double maxDeltaW = 0;
    for (AbsoluteDate date = fixedFieldEphemeris.getMinDate(); date
            .compareTo(fixedFieldEphemeris.getMaxDate()) < 0; date = date.shiftedBy(step)) {
        PVCoordinates pvFixedField = fixedFieldEphemeris.getPVCoordinates(date, FramesFactory.getGCRF());
        PVCoordinates pvVaryingField = varyingFieldEphemeris.getPVCoordinates(date, FramesFactory.getGCRF());
        Vector3D t = pvFixedField.getVelocity().normalize();
        Vector3D w = pvFixedField.getMomentum().normalize();
        Vector3D n = Vector3D.crossProduct(w, t);
        Vector3D delta = pvVaryingField.getPosition().subtract(pvFixedField.getPosition());
        maxDeltaT = FastMath.max(maxDeltaT, FastMath.abs(Vector3D.dotProduct(delta, t)));
        maxDeltaN = FastMath.max(maxDeltaN, FastMath.abs(Vector3D.dotProduct(delta, n)));
        maxDeltaW = FastMath.max(maxDeltaW, FastMath.abs(Vector3D.dotProduct(delta, w)));
    }
    Assert.assertTrue(maxDeltaT > 0.15);
    Assert.assertTrue(maxDeltaT < 0.25);
    Assert.assertTrue(maxDeltaN > 0.01);
    Assert.assertTrue(maxDeltaN < 0.02);
    Assert.assertTrue(maxDeltaW > 0.05);
    Assert.assertTrue(maxDeltaW < 0.10);

}

From source file:org.orekit.forces.gravity.ThirdBodyAttractionTest.java

@Test
public void testParameterDerivative() throws OrekitException {

    final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06,
            -1.32931592294715829e+04);//from  www  . j av  a  2  s .c o m
    final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03,
            -1.14097953925384523e+01);
    final SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel),
            FramesFactory.getGCRF(), new AbsoluteDate(2003, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()),
            Constants.EIGEN5C_EARTH_MU));

    final CelestialBody moon = CelestialBodyFactory.getMoon();
    final ThirdBodyAttraction forceModel = new ThirdBodyAttraction(moon);
    final String name = moon.getName() + ThirdBodyAttraction.ATTRACTION_COEFFICIENT_SUFFIX;
    checkParameterDerivative(state, forceModel, name, 1.0, 7.0e-15);

}

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);//w ww .  j  ava2 s .  c o  m
    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);/*  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)).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);//from w  w w . j  a  v  a  2s.  c  om
    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  ww  . jav a2  s  .  c o  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.forces.radiation.SolarRadiationPressureTest.java

@Test
public void testParameterDerivativeSphere() throws OrekitException {

    final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06,
            -1.32931592294715829e+04);/*w w w  .j  a v a2  s  .c  o  m*/
    final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03,
            -1.14097953925384523e+01);
    final SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel),
            FramesFactory.getGCRF(), new AbsoluteDate(2003, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()),
            Constants.EIGEN5C_EARTH_MU));

    SolarRadiationPressure forceModel = new SolarRadiationPressure(CelestialBodyFactory.getSun(),
            Constants.WGS84_EARTH_EQUATORIAL_RADIUS, new SphericalSpacecraft(2.5, 1.2, 0.7, 0.2));

    checkParameterDerivative(state, forceModel, RadiationSensitive.ABSORPTION_COEFFICIENT, 1.0, 5.0e-16);
    checkParameterDerivative(state, forceModel, RadiationSensitive.REFLECTION_COEFFICIENT, 1.0, 2.0e-15);

}