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 a, Vector3D u) 

Source Link

Document

Multiplicative constructor Build a vector from another one and a scale factor.

Usage

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

private double[][] hessian(final HolmesFeatherstoneAttractionModel model, final AbsoluteDate date,
        final Vector3D position, final double h) throws OrekitException {
    return new double[][] {
            differential8(model.gradient(date, position.add(new Vector3D(-4 * h, Vector3D.PLUS_I))),
                    model.gradient(date, position.add(new Vector3D(-3 * h, Vector3D.PLUS_I))),
                    model.gradient(date, position.add(new Vector3D(-2 * h, Vector3D.PLUS_I))),
                    model.gradient(date, position.add(new Vector3D(-1 * h, Vector3D.PLUS_I))),
                    model.gradient(date, position.add(new Vector3D(+1 * h, Vector3D.PLUS_I))),
                    model.gradient(date, position.add(new Vector3D(+2 * h, Vector3D.PLUS_I))),
                    model.gradient(date, position.add(new Vector3D(+3 * h, Vector3D.PLUS_I))),
                    model.gradient(date, position.add(new Vector3D(+4 * h, Vector3D.PLUS_I))), h),
            differential8(model.gradient(date, position.add(new Vector3D(-4 * h, Vector3D.PLUS_J))),
                    model.gradient(date, position.add(new Vector3D(-3 * h, Vector3D.PLUS_J))),
                    model.gradient(date, position.add(new Vector3D(-2 * h, Vector3D.PLUS_J))),
                    model.gradient(date, position.add(new Vector3D(-1 * h, Vector3D.PLUS_J))),
                    model.gradient(date, position.add(new Vector3D(+1 * h, Vector3D.PLUS_J))),
                    model.gradient(date, position.add(new Vector3D(+2 * h, Vector3D.PLUS_J))),
                    model.gradient(date, position.add(new Vector3D(+3 * h, Vector3D.PLUS_J))),
                    model.gradient(date, position.add(new Vector3D(+4 * h, Vector3D.PLUS_J))), h),
            differential8(model.gradient(date, position.add(new Vector3D(-4 * h, Vector3D.PLUS_K))),
                    model.gradient(date, position.add(new Vector3D(-3 * h, Vector3D.PLUS_K))),
                    model.gradient(date, position.add(new Vector3D(-2 * h, Vector3D.PLUS_K))),
                    model.gradient(date, position.add(new Vector3D(-1 * h, Vector3D.PLUS_K))),
                    model.gradient(date, position.add(new Vector3D(+1 * h, Vector3D.PLUS_K))),
                    model.gradient(date, position.add(new Vector3D(+2 * h, Vector3D.PLUS_K))),
                    model.gradient(date, position.add(new Vector3D(+3 * h, Vector3D.PLUS_K))),
                    model.gradient(date, position.add(new Vector3D(+4 * h, Vector3D.PLUS_K))), h) };
}

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

/** {@inheritDoc} */
public FieldVector3D<DerivativeStructure> accelerationDerivatives(final AbsoluteDate date, final Frame frame,
        final FieldVector3D<DerivativeStructure> position, final FieldVector3D<DerivativeStructure> velocity,
        final FieldRotation<DerivativeStructure> rotation, final DerivativeStructure mass)
        throws OrekitException {

    // compute bodies separation vectors and squared norm
    final Vector3D centralToBody = body.getPVCoordinates(date, frame).getPosition();
    final double r2Central = centralToBody.getNormSq();
    final FieldVector3D<DerivativeStructure> satToBody = position.subtract(centralToBody).negate();
    final DerivativeStructure r2Sat = satToBody.getNormSq();

    // compute relative acceleration
    final FieldVector3D<DerivativeStructure> satAcc = new FieldVector3D<DerivativeStructure>(
            r2Sat.sqrt().multiply(r2Sat).reciprocal().multiply(gm), satToBody);
    final Vector3D centralAcc = new Vector3D(gm / (r2Central * FastMath.sqrt(r2Central)), centralToBody);
    return satAcc.subtract(centralAcc);

}

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

/** {@inheritDoc} */
public void addContribution(final SpacecraftState s, final TimeDerivativesEquations adder)
        throws OrekitException {

    if (firing) {

        // compute thrust acceleration in inertial frame
        adder.addAcceleration(//ww  w  . j a va2  s  . c  om
                new Vector3D(thrust / s.getMass(), s.getAttitude().getRotation().applyInverseTo(direction)),
                s.getFrame());

        // compute flow rate
        adder.addMassDerivative(flowRate);

    }

}

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

@Test
public void testRoughBehaviour() throws OrekitException {
    final double isp = 318;
    final double mass = 2500;
    final double a = 24396159;
    final double e = 0.72831215;
    final double i = FastMath.toRadians(7);
    final double omega = FastMath.toRadians(180);
    final double OMEGA = FastMath.toRadians(261);
    final double lv = 0;

    final double duration = 3653.99;
    final double f = 420;
    final double delta = FastMath.toRadians(-7.4978);
    final double alpha = FastMath.toRadians(351);
    final AttitudeProvider law = new InertialProvider(
            new Rotation(new Vector3D(alpha, delta), Vector3D.PLUS_I));

    final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2004, 01, 01),
            new TimeComponents(23, 30, 00.000), TimeScalesFactory.getUTC());
    final Orbit orbit = new KeplerianOrbit(a, e, i, omega, OMEGA, lv, PositionAngle.TRUE,
            FramesFactory.getEME2000(), initDate, mu);
    final SpacecraftState initialState = new SpacecraftState(orbit,
            law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass);

    final AbsoluteDate fireDate = new AbsoluteDate(new DateComponents(2004, 01, 02),
            new TimeComponents(04, 15, 34.080), TimeScalesFactory.getUTC());
    final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(fireDate, duration, f, isp,
            Vector3D.PLUS_I);/*from ww w.  java 2s  .c o  m*/
    Assert.assertEquals(f, maneuver.getThrust(), 1.0e-10);
    Assert.assertEquals(isp, maneuver.getISP(), 1.0e-10);

    double[] absTolerance = { 0.001, 1.0e-9, 1.0e-9, 1.0e-6, 1.0e-6, 1.0e-6, 0.001 };
    double[] relTolerance = { 1.0e-7, 1.0e-4, 1.0e-4, 1.0e-7, 1.0e-7, 1.0e-7, 1.0e-7 };
    AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, absTolerance,
            relTolerance);
    integrator.setInitialStepSize(60);
    final NumericalPropagator propagator = new NumericalPropagator(integrator);
    propagator.setInitialState(initialState);
    propagator.setAttitudeProvider(law);
    propagator.addForceModel(maneuver);
    final SpacecraftState finalorb = propagator.propagate(fireDate.shiftedBy(3800));

    final double massTolerance = FastMath.abs(maneuver.getFlowRate())
            * maneuver.getEventsDetectors()[0].getThreshold();
    Assert.assertEquals(2007.8824544261233, finalorb.getMass(), massTolerance);
    Assert.assertEquals(2.6872, FastMath.toDegrees(MathUtils.normalizeAngle(finalorb.getI(), FastMath.PI)),
            1e-4);
    Assert.assertEquals(28970, finalorb.getA() / 1000, 1);

}

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

@Test
public void testInclinationManeuver() throws OrekitException {
    final Orbit initialOrbit = new KeplerianOrbit(24532000.0, 0.72, 0.3, FastMath.PI, 0.4, 2.0,
            PositionAngle.MEAN, FramesFactory.getEME2000(), new AbsoluteDate(new DateComponents(2008, 06, 23),
                    new TimeComponents(14, 18, 37), TimeScalesFactory.getUTC()),
            3.986004415e14);// ww w .ja v  a  2  s  .com
    final double a = initialOrbit.getA();
    final double e = initialOrbit.getE();
    final double i = initialOrbit.getI();
    final double mu = initialOrbit.getMu();
    final double vApo = FastMath.sqrt(mu * (1 - e) / (a * (1 + e)));
    double dv = 0.99 * FastMath.tan(i) * vApo;
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit,
            new LofOffset(initialOrbit.getFrame(), LOFType.VVLH));
    propagator.addEventDetector(
            new ImpulseManeuver<NodeDetector>(new NodeDetector(initialOrbit, FramesFactory.getEME2000()),
                    new Vector3D(dv, Vector3D.PLUS_J), 400.0));
    SpacecraftState propagated = propagator.propagate(initialOrbit.getDate().shiftedBy(8000));
    Assert.assertEquals(0.0028257, propagated.getI(), 1.0e-6);
}

From source file:org.orekit.forces.radiation.SolarRadiationPressure.java

/** {@inheritDoc} */
public void addContribution(final SpacecraftState s, final TimeDerivativesEquations adder)
        throws OrekitException {

    final AbsoluteDate date = s.getDate();
    final Frame frame = s.getFrame();
    final Vector3D position = s.getPVCoordinates().getPosition();
    final Vector3D sunSatVector = position.subtract(sun.getPVCoordinates(date, frame).getPosition());
    final double r2 = sunSatVector.getNormSq();

    // compute flux
    final double rawP = kRef * getLightningRatio(position, frame, date) / r2;
    final Vector3D flux = new Vector3D(rawP / FastMath.sqrt(r2), sunSatVector);

    final Vector3D acceleration = spacecraft.radiationPressureAcceleration(date, frame, position,
            s.getAttitude().getRotation(), s.getMass(), flux);

    // provide the perturbing acceleration to the derivatives adder
    adder.addAcceleration(acceleration, s.getFrame());

}

From source file:org.orekit.forces.radiation.SolarRadiationPressure.java

/** {@inheritDoc} */
public FieldVector3D<DerivativeStructure> accelerationDerivatives(final SpacecraftState s,
        final String paramName) throws OrekitException {

    complainIfNotSupported(paramName);//  w w w.java 2s . c  om
    final AbsoluteDate date = s.getDate();
    final Frame frame = s.getFrame();
    final Vector3D position = s.getPVCoordinates().getPosition();
    final Vector3D sunSatVector = position.subtract(sun.getPVCoordinates(date, frame).getPosition());
    final double r2 = sunSatVector.getNormSq();

    // compute flux
    final double rawP = kRef * getLightningRatio(position, frame, date) / r2;
    final Vector3D flux = new Vector3D(rawP / FastMath.sqrt(r2), sunSatVector);

    return spacecraft.radiationPressureAcceleration(date, frame, position, s.getAttitude().getRotation(),
            s.getMass(), flux, paramName);

}

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

/** {@inheritDoc} */
public Vector3D dragAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position,
        final Rotation rotation, final double mass, final double density, final Vector3D relativeVelocity) {
    return new Vector3D(relativeVelocity.getNorm() * density * dragCoeff * crossSection / (2 * mass),
            relativeVelocity);/*  w  w  w.j  a v a 2 s  .co m*/
}

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

/** {@inheritDoc} */
public Vector3D radiationPressureAcceleration(final AbsoluteDate date, final Frame frame,
        final Vector3D position, final Rotation rotation, final double mass, final Vector3D flux) {
    final double kP = crossSection * (1 + 4 * (1.0 - absorptionCoeff) * (1.0 - specularReflectionCoeff) / 9.0);
    return new Vector3D(kP / mass, flux);
}

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

/** Get the transform from TOD at specified date.
 * <p>The update considers the Earth rotation from IERS data.</p>
 * @param date new value of the date/*from  w  w w .j a  v  a 2s. com*/
 * @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 {

    // compute Greenwich apparent sidereal time, in radians
    final double gast = gastFunction.value(date).getValue();

    // compute true angular rotation of Earth, in rad/s
    final double lod = (eopHistory == null) ? 0.0 : eopHistory.getLOD(date);
    final double omp = AVE * (1 - lod / Constants.JULIAN_DAY);
    final Vector3D rotationRate = new Vector3D(omp, Vector3D.PLUS_K);

    // set up the transform from parent TOD
    return new Transform(date, new Rotation(Vector3D.PLUS_K, -gast), rotationRate);

}