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

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

Introduction

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

Prototype

public Vector3D add(final Vector<Euclidean3D> v) 

Source Link

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;
    }/*from w  w w.  j  av 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.gravity.HolmesFeatherstoneAttractionModelTest.java

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

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.frames.ITRFProviderWithoutTidalEffectsTest.java

@Test
public void testMSLIBTransformJ2000_TerRef() throws OrekitException {

    AbsoluteDate t0 = new AbsoluteDate(new DateComponents(2003, 10, 14), new TimeComponents(02, 00, 00),
            TimeScalesFactory.getUTC());
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    Transform trans = FramesFactory.getEME2000().getTransformTo(itrf, t0);

    // Coordinates in EME2000
    PVCoordinates pvEME2000 = new PVCoordinates(new Vector3D(6500000.0, -1234567.0, 4000000.0),
            new Vector3D(3609.28229, 3322.88979, -7083.950661));

    // Reference coordinates in ITRF
    PVCoordinates pvRef = new PVCoordinates(
            new Vector3D(3011113.971820046, -5889827.854375269, 4002158.938875904),
            new Vector3D(4410.393506651586, -1033.61784235127, -7082.633883124906));

    // tests using direct transform
    checkPV(pvRef, trans.transformPVCoordinates(pvEME2000), 0.594, 1.79e-4);

    // compute local evolution using finite differences
    double h = 1.0;
    Rotation r0 = trans.getRotation();/*from  w w  w. j ava2s.c om*/
    AbsoluteDate date = t0.shiftedBy(-2 * h);
    Rotation evoM2h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert());
    double alphaM2h = -evoM2h.getAngle();
    Vector3D axisM2h = evoM2h.getAxis();
    date = t0.shiftedBy(-h);
    Rotation evoM1h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert());
    double alphaM1h = -evoM1h.getAngle();
    Vector3D axisM1h = evoM1h.getAxis();
    date = t0.shiftedBy(h);
    Rotation evoP1h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert());
    double alphaP1h = evoP1h.getAngle();
    Vector3D axisP1h = evoP1h.getAxis().negate();
    date = t0.shiftedBy(2 * h);
    Rotation evoP2h = FramesFactory.getEME2000().getTransformTo(itrf, date).getRotation().applyTo(r0.revert());
    double alphaP2h = evoP2h.getAngle();
    Vector3D axisP2h = evoP2h.getAxis().negate();
    double w = (8 * (alphaP1h - alphaM1h) - (alphaP2h - alphaM2h)) / (12 * h);
    Vector3D axis = axisM2h.add(axisM1h).add(axisP1h.add(axisP2h)).normalize();
    Transform finiteDiffTransform = new Transform(t0, trans.getRotation(), new Vector3D(w, axis));

    checkPV(pvRef, finiteDiffTransform.transformPVCoordinates(pvEME2000), 0.594, 1.78e-4);

}

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

/** Compute a composite translation.
 * @param first first applied transform// ww w .  j a va 2  s.  c  om
 * @param second second applied transform
 * @return translation part of the composite transform
 */
private static Vector3D compositeTranslation(final Transform first, final Transform second) {

    final Vector3D p1 = first.cartesian.getPosition();
    final Rotation r1 = first.angular.getRotation();
    final Vector3D p2 = second.cartesian.getPosition();

    return p1.add(r1.applyInverseTo(p2));

}

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

/** Compute a composite velocity.
 * @param first first applied transform/*from www . j  av a  2s.  c o  m*/
 * @param second second applied transform
 * @return velocity part of the composite transform
 */
private static Vector3D compositeVelocity(final Transform first, final Transform second) {

    final Vector3D v1 = first.cartesian.getVelocity();
    final Rotation r1 = first.angular.getRotation();
    final Vector3D o1 = first.angular.getRotationRate();
    final Vector3D p2 = second.cartesian.getPosition();
    final Vector3D v2 = second.cartesian.getVelocity();

    final Vector3D crossP = Vector3D.crossProduct(o1, p2);

    return v1.add(r1.applyInverseTo(v2.add(crossP)));

}

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

/** Compute a composite acceleration.
 * @param first first applied transform//from ww w.  j a  v a  2  s . c o m
 * @param second second applied transform
 * @return acceleration part of the composite transform
 */
private static Vector3D compositeAcceleration(final Transform first, final Transform second) {

    final Vector3D a1 = first.cartesian.getAcceleration();
    final Rotation r1 = first.angular.getRotation();
    final Vector3D o1 = first.angular.getRotationRate();
    final Vector3D oDot1 = first.angular.getRotationAcceleration();
    final Vector3D p2 = second.cartesian.getPosition();
    final Vector3D v2 = second.cartesian.getVelocity();
    final Vector3D a2 = second.cartesian.getAcceleration();

    final Vector3D crossCrossP = Vector3D.crossProduct(o1, Vector3D.crossProduct(o1, p2));
    final Vector3D crossV = Vector3D.crossProduct(o1, v2);
    final Vector3D crossDotP = Vector3D.crossProduct(oDot1, p2);

    return a1.add(r1.applyInverseTo(new Vector3D(1, a2, 2, crossV, 1, crossCrossP, 1, crossDotP)));

}

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

/** Compute a composite rotation rate.
 * @param first first applied transform/*from w w w  . jav  a  2s  .  c  o m*/
 * @param second second applied transform
 * @return rotation rate part of the composite transform
 */
private static Vector3D compositeRotationRate(final Transform first, final Transform second) {

    final Vector3D o1 = first.angular.getRotationRate();
    final Rotation r2 = second.angular.getRotation();
    final Vector3D o2 = second.angular.getRotationRate();

    return o2.add(r2.applyTo(o1));

}

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

@Test
public void testTransPV() {

    RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l);

    // translation velocity only :

    for (int i = 0; i < 10; ++i) {

        // random position, velocity and acceleration
        Vector3D pos = randomVector(1.0e3, rnd);
        Vector3D vel = randomVector(1.0, rnd);
        Vector3D acc = randomVector(1.0e-3, rnd);
        PVCoordinates pvOne = new PVCoordinates(pos, vel, acc);

        // random transform
        Vector3D transPos = randomVector(1.0e3, rnd);
        Vector3D transVel = randomVector(1.0, rnd);
        Vector3D transAcc = randomVector(1.0e-3, rnd);
        Transform tr = new Transform(AbsoluteDate.J2000_EPOCH, transPos, transVel, transAcc);

        double dt = 1;

        // we should obtain
        Vector3D good = tr.transformPosition(pos.add(new Vector3D(dt, vel))).add(new Vector3D(dt, transVel));

        // we have
        PVCoordinates pvTwo = tr.transformPVCoordinates(pvOne);
        Vector3D result = pvTwo.getPosition().add(new Vector3D(dt, pvTwo.getVelocity()));
        checkVector(good, result, 1.0e-15);

        // test inverse
        Vector3D resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity();
        checkVector(resultvel, vel, 1.0e-15);

    }/*  w  w  w . j a v a  2  s.  c  o  m*/

}

From source file:org.orekit.models.earth.GeoidTest.java

/**
 * check {@link Geoid#getIntersectionPoint(Line, Vector3D, Frame,
 * AbsoluteDate)} with several points./*from  w w  w .  j av  a 2 s.com*/
 *
 * @throws OrekitException on error
 */
@Test
public void testGetIntersectionPoint() throws OrekitException {
    // setup
    Geoid geoid = getComponent();
    Frame frame = geoid.getBodyFrame();

    for (double[] point : reference) {
        GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(point[0]), FastMath.toRadians(point[1]), 0);
        Vector3D expected = geoid.transform(gp);
        // glancing line: 10% vertical and 90% north (~6 deg elevation)
        Vector3D slope = gp.getZenith().scalarMultiply(0.1).add(gp.getNorth().scalarMultiply(0.9));
        Vector3D close = expected.add(slope.scalarMultiply(100e3));
        Vector3D pointOnLine = expected.add(slope);
        Line line = new Line(close, pointOnLine, 0);
        // line directed the other way
        Line otherDirection = new Line(pointOnLine, close, 0);

        // action
        GeodeticPoint actual = geoid.getIntersectionPoint(line, close, frame, date);
        // other direction
        GeodeticPoint actualReversed = geoid.getIntersectionPoint(otherDirection, close, frame, date);

        // verify
        String message = String.format("point: %s%n", Arrays.toString(point));
        // position accuracy on Earth's surface to 1 um.
        assertThat(message, actualReversed, geodeticPointCloseTo(gp, 1e-6));
        assertThat(message, actual, geodeticPointCloseTo(gp, 1e-6));
    }
}