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

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

Introduction

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

Prototype

public double getY() 

Source Link

Document

Get the ordinate of the vector.

Usage

From source file:org.orekit.orbits.KeplerianParametersTest.java

@Test
public void testKeplerianDerivatives() {
    final KeplerianOrbit o = new KeplerianOrbit(new PVCoordinates(new Vector3D(-4947831., -3765382., -3708221.),
            new Vector3D(-2079., 5291., -7842.)), FramesFactory.getEME2000(), date, 3.9860047e14);
    final Vector3D p = o.getPVCoordinates().getPosition();
    final Vector3D v = o.getPVCoordinates().getVelocity();
    final Vector3D a = o.getPVCoordinates().getAcceleration();

    // check that despite we did not provide acceleration, it got recomputed
    Assert.assertEquals(7.605422, a.getNorm(), 1.0e-6);

    FiniteDifferencesDifferentiator differentiator = new FiniteDifferencesDifferentiator(8, 0.1);

    // check velocity is the derivative of position
    double vx = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getPosition().getX();
        }//from  w w  w . ja  v a2 s .  c om
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(o.getPVCoordinates().getVelocity().getX(), vx, 3.0e-12 * v.getNorm());
    double vy = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getPosition().getY();
        }
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(o.getPVCoordinates().getVelocity().getY(), vy, 3.0e-12 * v.getNorm());
    double vz = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getPosition().getZ();
        }
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(o.getPVCoordinates().getVelocity().getZ(), vz, 3.0e-12 * v.getNorm());

    // check acceleration is the derivative of velocity
    double ax = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getVelocity().getX();
        }
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(o.getPVCoordinates().getAcceleration().getX(), ax, 3.0e-12 * a.getNorm());
    double ay = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getVelocity().getY();
        }
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(o.getPVCoordinates().getAcceleration().getY(), ay, 3.0e-12 * a.getNorm());
    double az = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getVelocity().getZ();
        }
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(o.getPVCoordinates().getAcceleration().getZ(), az, 3.0e-12 * a.getNorm());

    // check jerk is the derivative of acceleration
    final double r2 = p.getNormSq();
    final double r = FastMath.sqrt(r2);
    Vector3D keplerianJerk = new Vector3D(-3 * Vector3D.dotProduct(p, v) / r2, a, -a.getNorm() / r, v);
    double jx = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getAcceleration().getX();
        }
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(keplerianJerk.getX(), jx, 3.0e-12 * keplerianJerk.getNorm());
    double jy = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getAcceleration().getY();
        }
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(keplerianJerk.getY(), jy, 3.0e-12 * keplerianJerk.getNorm());
    double jz = differentiator.differentiate(new UnivariateFunction() {
        public double value(double dt) {
            return o.shiftedBy(dt).getPVCoordinates().getAcceleration().getZ();
        }
    }).value(new DerivativeStructure(1, 1, 0, 0.0)).getPartialDerivative(1);
    Assert.assertEquals(keplerianJerk.getZ(), jz, 3.0e-12 * keplerianJerk.getNorm());

}

From source file:org.orekit.orbits.Orbit.java

/** Fill a Jacobian half row with a single vector.
* @param a coefficient of the vector/*from  ww w .j  a  v a2 s .  c  o  m*/
* @param v vector
* @param row Jacobian matrix row
* @param j index of the first element to set (row[j], row[j+1] and row[j+2] will all be set)
*/
protected static void fillHalfRow(final double a, final Vector3D v, final double[] row, final int j) {
    row[j] = a * v.getX();
    row[j + 1] = a * v.getY();
    row[j + 2] = a * v.getZ();
}

From source file:org.orekit.orbits.Orbit.java

/** Fill a Jacobian half row with a linear combination of vectors.
 * @param a1 coefficient of the first vector
 * @param v1 first vector//from ww w  .  jav  a2s  .com
 * @param a2 coefficient of the second vector
 * @param v2 second vector
 * @param row Jacobian matrix row
 * @param j index of the first element to set (row[j], row[j+1] and row[j+2] will all be set)
 */
protected static void fillHalfRow(final double a1, final Vector3D v1, final double a2, final Vector3D v2,
        final double[] row, final int j) {
    row[j] = a1 * v1.getX() + a2 * v2.getX();
    row[j + 1] = a1 * v1.getY() + a2 * v2.getY();
    row[j + 2] = a1 * v1.getZ() + a2 * v2.getZ();
}

From source file:org.orekit.orbits.Orbit.java

/** Fill a Jacobian half row with a linear combination of vectors.
 * @param a1 coefficient of the first vector
 * @param v1 first vector/*from   www .  java 2  s  . c o  m*/
 * @param a2 coefficient of the second vector
 * @param v2 second vector
 * @param a3 coefficient of the third vector
 * @param v3 third vector
 * @param row Jacobian matrix row
 * @param j index of the first element to set (row[j], row[j+1] and row[j+2] will all be set)
 */
protected static void fillHalfRow(final double a1, final Vector3D v1, final double a2, final Vector3D v2,
        final double a3, final Vector3D v3, final double[] row, final int j) {
    row[j] = a1 * v1.getX() + a2 * v2.getX() + a3 * v3.getX();
    row[j + 1] = a1 * v1.getY() + a2 * v2.getY() + a3 * v3.getY();
    row[j + 2] = a1 * v1.getZ() + a2 * v2.getZ() + a3 * v3.getZ();
}

From source file:org.orekit.orbits.Orbit.java

/** Fill a Jacobian half row with a linear combination of vectors.
 * @param a1 coefficient of the first vector
 * @param v1 first vector//from  ww  w.j av  a 2s  .com
 * @param a2 coefficient of the second vector
 * @param v2 second vector
 * @param a3 coefficient of the third vector
 * @param v3 third vector
 * @param a4 coefficient of the fourth vector
 * @param v4 fourth vector
 * @param row Jacobian matrix row
 * @param j index of the first element to set (row[j], row[j+1] and row[j+2] will all be set)
 */
protected static void fillHalfRow(final double a1, final Vector3D v1, final double a2, final Vector3D v2,
        final double a3, final Vector3D v3, final double a4, final Vector3D v4, final double[] row,
        final int j) {
    row[j] = a1 * v1.getX() + a2 * v2.getX() + a3 * v3.getX() + a4 * v4.getX();
    row[j + 1] = a1 * v1.getY() + a2 * v2.getY() + a3 * v3.getY() + a4 * v4.getY();
    row[j + 2] = a1 * v1.getZ() + a2 * v2.getZ() + a3 * v3.getZ() + a4 * v4.getZ();
}

From source file:org.orekit.orbits.Orbit.java

/** Fill a Jacobian half row with a linear combination of vectors.
 * @param a1 coefficient of the first vector
 * @param v1 first vector/*  w w  w .j  ava 2  s .com*/
 * @param a2 coefficient of the second vector
 * @param v2 second vector
 * @param a3 coefficient of the third vector
 * @param v3 third vector
 * @param a4 coefficient of the fourth vector
 * @param v4 fourth vector
 * @param a5 coefficient of the fifth vector
 * @param v5 fifth vector
 * @param row Jacobian matrix row
 * @param j index of the first element to set (row[j], row[j+1] and row[j+2] will all be set)
 */
protected static void fillHalfRow(final double a1, final Vector3D v1, final double a2, final Vector3D v2,
        final double a3, final Vector3D v3, final double a4, final Vector3D v4, final double a5,
        final Vector3D v5, final double[] row, final int j) {
    row[j] = a1 * v1.getX() + a2 * v2.getX() + a3 * v3.getX() + a4 * v4.getX() + a5 * v5.getX();
    row[j + 1] = a1 * v1.getY() + a2 * v2.getY() + a3 * v3.getY() + a4 * v4.getY() + a5 * v5.getY();
    row[j + 2] = a1 * v1.getZ() + a2 * v2.getZ() + a3 * v3.getZ() + a4 * v4.getZ() + a5 * v5.getZ();
}

From source file:org.orekit.orbits.Orbit.java

/** Fill a Jacobian half row with a linear combination of vectors.
 * @param a1 coefficient of the first vector
 * @param v1 first vector/*from w  w  w .  j  a v  a 2s.c  o m*/
 * @param a2 coefficient of the second vector
 * @param v2 second vector
 * @param a3 coefficient of the third vector
 * @param v3 third vector
 * @param a4 coefficient of the fourth vector
 * @param v4 fourth vector
 * @param a5 coefficient of the fifth vector
 * @param v5 fifth vector
 * @param a6 coefficient of the sixth vector
 * @param v6 sixth vector
 * @param row Jacobian matrix row
 * @param j index of the first element to set (row[j], row[j+1] and row[j+2] will all be set)
 */
protected static void fillHalfRow(final double a1, final Vector3D v1, final double a2, final Vector3D v2,
        final double a3, final Vector3D v3, final double a4, final Vector3D v4, final double a5,
        final Vector3D v5, final double a6, final Vector3D v6, final double[] row, final int j) {
    row[j] = a1 * v1.getX() + a2 * v2.getX() + a3 * v3.getX() + a4 * v4.getX() + a5 * v5.getX()
            + a6 * v6.getX();
    row[j + 1] = a1 * v1.getY() + a2 * v2.getY() + a3 * v3.getY() + a4 * v4.getY() + a5 * v5.getY()
            + a6 * v6.getY();
    row[j + 2] = a1 * v1.getZ() + a2 * v2.getZ() + a3 * v3.getZ() + a4 * v4.getZ() + a5 * v5.getZ()
            + a6 * v6.getZ();
}

From source file:org.orekit.OrekitMatchers.java

/**
 * Matches a {@link Vector3D} based on its three coordinates.
 *
 * @param x matcher for the x coordinate
 * @param y matcher for the y coordinate
 * @param z matcher for the z coordinate
 * @return a vector matcher//from  w w  w  . j  a  va2  s .co  m
 */
public static Matcher<Vector3D> vector(final Matcher<Double> x, final Matcher<Double> y,
        final Matcher<Double> z) {
    return new TypeSafeDiagnosingMatcher<Vector3D>() {
        @Override
        public void describeTo(Description description) {
            description.appendList("Vector3D[", ",", "]", Arrays.<SelfDescribing>asList(x, y, z));
        }

        @Override
        protected boolean matchesSafely(Vector3D item, Description mismatchDescription) {
            if (!x.matches(item.getX())) {
                mismatchDescription.appendText("the x coordinate ");
                x.describeMismatch(item.getX(), mismatchDescription);
                return false;
            }
            if (!y.matches(item.getY())) {
                mismatchDescription.appendText("the y coordinate ");
                y.describeMismatch(item.getY(), mismatchDescription);
                return false;
            }
            if (!z.matches(item.getZ())) {
                mismatchDescription.appendText("the z coordinate ");
                z.describeMismatch(item.getZ(), mismatchDescription);
                return false;
            }
            return true;
        }
    };
}

From source file:org.orekit.OrekitMatchers.java

/**
 * Matches a {@link Vector3D} close to another one.
 *
 * @param vector the reference vector/*  ww  w. j av a  2s  .c  o m*/
 * @param absTol absolute tolerance of comparison, in each dimension
 * @return a vector matcher.
 */
public static Matcher<Vector3D> vectorCloseTo(Vector3D vector, double absTol) {
    return vector(closeTo(vector.getX(), absTol), closeTo(vector.getY(), absTol),
            closeTo(vector.getZ(), absTol));
}

From source file:org.orekit.OrekitMatchers.java

/**
 * Matches a {@link Vector3D} close to another one.
 *
 * @param vector the reference vector//w  w  w  .  jav  a  2  s .co  m
 * @param ulps   the relative tolerance, in units in last place, of the
 *               Comparison of each dimension.
 * @return a vector matcher.
 */
public static Matcher<Vector3D> vectorCloseTo(Vector3D vector, int ulps) {
    return vector(relativelyCloseTo(vector.getX(), ulps), relativelyCloseTo(vector.getY(), ulps),
            relativelyCloseTo(vector.getZ(), ulps));
}