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

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

Introduction

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

Prototype

public FieldVector3D(final double a, final FieldVector3D<T> u) 

Source Link

Document

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

Usage

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

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

    // relative velocity in spacecraft frame
    final FieldVector3D<DerivativeStructure> v = rotation.applyTo(relativeVelocity);

    // solar array contribution
    final FieldVector3D<DerivativeStructure> solarArrayFacet = new FieldVector3D<DerivativeStructure>(
            solarArrayArea, getNormal(date, frame, position, rotation));
    DerivativeStructure sv = FieldVector3D.dotProduct(v, solarArrayFacet).abs();

    // body facets contribution
    for (final Facet facet : facets) {
        final DerivativeStructure dot = FieldVector3D.dotProduct(v, facet.getNormal());
        if (dot.getValue() < 0) {
            // the facet intercepts the incoming flux
            sv = sv.subtract(dot.multiply(facet.getArea()));
        }/*from ww  w  .ja  v a2 s . c om*/
    }

    return new FieldVector3D<DerivativeStructure>(sv.multiply(density * dragCoeff / 2.0).divide(mass),
            relativeVelocity);

}

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

/** {@inheritDoc} */
public FieldVector3D<DerivativeStructure> dragAcceleration(final AbsoluteDate date, final Frame frame,
        final Vector3D position, final Rotation rotation, final double mass, final double density,
        final Vector3D relativeVelocity, final String paramName) throws OrekitException {

    if (!DRAG_COEFFICIENT.equals(paramName)) {
        throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, DRAG_COEFFICIENT);
    }// w ww  . java 2  s.c  om

    final DerivativeStructure dragCoeffDS = new DerivativeStructure(1, 1, 0, dragCoeff);

    // relative velocity in spacecraft frame
    final Vector3D v = rotation.applyTo(relativeVelocity);

    // solar array contribution
    final Vector3D solarArrayFacet = new Vector3D(solarArrayArea, getNormal(date, frame, position, rotation));
    double sv = FastMath.abs(Vector3D.dotProduct(solarArrayFacet, v));

    // body facets contribution
    for (final Facet facet : facets) {
        final double dot = Vector3D.dotProduct(facet.getNormal(), v);
        if (dot < 0) {
            // the facet intercepts the incoming flux
            sv -= facet.getArea() * dot;
        }
    }

    return new FieldVector3D<DerivativeStructure>(dragCoeffDS.multiply(sv * density / (2.0 * mass)),
            relativeVelocity);

}

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

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

    if (flux.getNormSq().getValue() < Precision.SAFE_MIN) {
        // null illumination (we are probably in umbra)
        return new FieldVector3D<DerivativeStructure>(0.0, flux);
    }/*from   w w w  .  ja  va2  s.  c o m*/

    // radiation flux in spacecraft frame
    final FieldVector3D<DerivativeStructure> fluxSat = rotation.applyTo(flux);

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

    // body facets contribution
    for (final Facet bodyFacet : facets) {
        normal = new FieldVector3D<DerivativeStructure>(mass.getField().getOne(), bodyFacet.getNormal());
        dot = FieldVector3D.dotProduct(normal, fluxSat);
        if (dot.getValue() < 0) {
            // the facet intercepts the incoming flux
            force = force.add(facetRadiationAcceleration(normal, bodyFacet.getArea(), fluxSat, dot));
        }
    }

    // convert to inertial frame
    return rotation.applyInverseTo(new FieldVector3D<DerivativeStructure>(mass.reciprocal(), force));

}

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

@Test
public void testStateJacobian() throws OrekitException {

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

    // initialization
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2000, 07, 01), new TimeComponents(13, 59, 27.816),
            TimeScalesFactory.getUTC());
    double i = FastMath.toRadians(98.7);
    double omega = FastMath.toRadians(93.0);
    double OMEGA = FastMath.toRadians(15.0 * 22.5);
    Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, i, omega, OMEGA, 0, PositionAngle.MEAN,
            FramesFactory.getEME2000(), date, mu);
    OrbitType integrationType = OrbitType.CARTESIAN;
    double[][] tolerances = NumericalPropagator.tolerances(0.01, orbit, integrationType);

    propagator = new NumericalPropagator(
            new DormandPrince853Integrator(1.0e-3, 120, tolerances[0], tolerances[1]));
    propagator.setOrbitType(integrationType);
    CunninghamAttractionModel cuModel = new CunninghamAttractionModel(itrf2008,
            GravityFieldFactory.getUnnormalizedProvider(50, 50));
    Assert.assertEquals(TideSystem.UNKNOWN, cuModel.getTideSystem());
    propagator.addForceModel(cuModel);/*from ww w.  j a  v  a2  s.  co m*/
    SpacecraftState state0 = new SpacecraftState(orbit);
    propagator.setInitialState(state0);
    try {
        DerivativeStructure one = new DerivativeStructure(7, 1, 1.0);
        cuModel.accelerationDerivatives(state0.getDate(), state0.getFrame(),
                new FieldVector3D<DerivativeStructure>(one, state0.getPVCoordinates().getPosition()),
                new FieldVector3D<DerivativeStructure>(one, state0.getPVCoordinates().getVelocity()),
                new FieldRotation<DerivativeStructure>(one.multiply(state0.getAttitude().getRotation().getQ0()),
                        one.multiply(state0.getAttitude().getRotation().getQ1()),
                        one.multiply(state0.getAttitude().getRotation().getQ2()),
                        one.multiply(state0.getAttitude().getRotation().getQ3()), false),
                one.multiply(state0.getMass()));
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.STEPS_NOT_INITIALIZED_FOR_FINITE_DIFFERENCES, oe.getSpecifier());
    }
    cuModel.setSteps(1.0, 1.0e10);

    checkStateJacobian(propagator, state0, date.shiftedBy(3.5 * 3600.0), 40000, tolerances[0], 2.0e-7);
}

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

@Test
public void testStateJacobian() throws OrekitException {

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

    // initialization
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2000, 07, 01), new TimeComponents(13, 59, 27.816),
            TimeScalesFactory.getUTC());
    double i = FastMath.toRadians(98.7);
    double omega = FastMath.toRadians(93.0);
    double OMEGA = FastMath.toRadians(15.0 * 22.5);
    Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, i, omega, OMEGA, 0, PositionAngle.MEAN,
            FramesFactory.getEME2000(), date, mu);
    OrbitType integrationType = OrbitType.CARTESIAN;
    double[][] tolerances = NumericalPropagator.tolerances(0.01, orbit, integrationType);

    propagator = new NumericalPropagator(
            new DormandPrince853Integrator(1.0e-3, 120, tolerances[0], tolerances[1]));
    propagator.setOrbitType(integrationType);
    DrozinerAttractionModel drModel = new DrozinerAttractionModel(itrf2008,
            GravityFieldFactory.getUnnormalizedProvider(50, 50));
    Assert.assertEquals(TideSystem.UNKNOWN, drModel.getTideSystem());
    propagator.addForceModel(drModel);/*w  w  w. j  a  v  a2  s.co  m*/
    SpacecraftState state0 = new SpacecraftState(orbit);
    propagator.setInitialState(state0);
    try {
        DerivativeStructure one = new DerivativeStructure(7, 1, 1.0);
        drModel.accelerationDerivatives(state0.getDate(), state0.getFrame(),
                new FieldVector3D<DerivativeStructure>(one, state0.getPVCoordinates().getPosition()),
                new FieldVector3D<DerivativeStructure>(one, state0.getPVCoordinates().getVelocity()),
                new FieldRotation<DerivativeStructure>(one.multiply(state0.getAttitude().getRotation().getQ0()),
                        one.multiply(state0.getAttitude().getRotation().getQ1()),
                        one.multiply(state0.getAttitude().getRotation().getQ2()),
                        one.multiply(state0.getAttitude().getRotation().getQ3()), false),
                one.multiply(state0.getMass()));
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.STEPS_NOT_INITIALIZED_FOR_FINITE_DIFFERENCES, oe.getSpecifier());
    }
    drModel.setSteps(1.0, 1.0e10);

    checkStateJacobian(propagator, state0, date.shiftedBy(3.5 * 3600.0), 40000, tolerances[0], 2.0e-7);

}

From source file:org.orekit.forces.gravity.NewtonianAttraction.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 {

    final DerivativeStructure r2 = position.getNormSq();
    return new FieldVector3D<DerivativeStructure>(r2.sqrt().multiply(r2).reciprocal().multiply(-mu), position);

}

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

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

    complainIfNotSupported(paramName);//w w w  .j  av  a 2  s. co  m

    final Vector3D position = s.getPVCoordinates().getPosition();
    final double r2 = position.getNormSq();
    final DerivativeStructure muds = new DerivativeStructure(1, 1, 0, mu);
    return new FieldVector3D<DerivativeStructure>(muds.divide(-r2 * FastMath.sqrt(r2)), position);

}

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 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 {
    if (firing) {
        return new FieldVector3D<DerivativeStructure>(mass.reciprocal().multiply(thrust),
                rotation.applyInverseTo(direction));
    } else {//from  ww  w.j av  a2  s.c o m
        // constant (and null) acceleration when not firing
        final int parameters = mass.getFreeParameters();
        final int order = mass.getOrder();
        return new FieldVector3D<DerivativeStructure>(new DerivativeStructure(parameters, order, 0.0),
                new DerivativeStructure(parameters, order, 0.0),
                new DerivativeStructure(parameters, order, 0.0));
    }
}

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

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

    complainIfNotSupported(paramName);//from  w ww.  j av  a 2 s .c  o m

    if (firing) {

        if (THRUST.equals(paramName)) {
            final DerivativeStructure thrustDS = new DerivativeStructure(1, 1, 0, thrust);
            return new FieldVector3D<DerivativeStructure>(thrustDS.divide(s.getMass()),
                    s.getAttitude().getRotation().applyInverseTo(direction));
        } else if (FLOW_RATE.equals(paramName)) {
            // acceleration does not depend on flow rate (only mass decrease does)
            final DerivativeStructure zero = new DerivativeStructure(1, 1, 0.0);
            return new FieldVector3D<DerivativeStructure>(zero, zero, zero);
        } else {
            throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName,
                    THRUST + ", " + FLOW_RATE);
        }

    } else {
        // constant (and null) acceleration when not firing
        final DerivativeStructure zero = new DerivativeStructure(1, 1, 0.0);
        return new FieldVector3D<DerivativeStructure>(zero, zero, zero);
    }

}