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.utils.TimeStampedPVCoordinatesTest.java

@Test
public void testInterpolatePolynomialPV() {
    Random random = new Random(0xae7771c9933407bdl);
    AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH;
    for (int i = 0; i < 20; ++i) {

        PolynomialFunction px = randomPolynomial(5, random);
        PolynomialFunction py = randomPolynomial(5, random);
        PolynomialFunction pz = randomPolynomial(5, random);
        PolynomialFunction pxDot = px.polynomialDerivative();
        PolynomialFunction pyDot = py.polynomialDerivative();
        PolynomialFunction pzDot = pz.polynomialDerivative();
        PolynomialFunction pxDotDot = pxDot.polynomialDerivative();
        PolynomialFunction pyDotDot = pyDot.polynomialDerivative();
        PolynomialFunction pzDotDot = pzDot.polynomialDerivative();

        List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
        for (double dt : new double[] { 0.0, 0.5, 1.0 }) {
            Vector3D position = new Vector3D(px.value(dt), py.value(dt), pz.value(dt));
            Vector3D velocity = new Vector3D(pxDot.value(dt), pyDot.value(dt), pzDot.value(dt));
            sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, velocity, Vector3D.ZERO));
        }//from  w w  w  .j a  v  a2s . co  m

        for (double dt = 0; dt < 1.0; dt += 0.01) {
            TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt),
                    CartesianDerivativesFilter.USE_PV, sample);
            Vector3D p = interpolated.getPosition();
            Vector3D v = interpolated.getVelocity();
            Vector3D a = interpolated.getAcceleration();
            Assert.assertEquals(px.value(dt), p.getX(), 4.0e-16 * p.getNorm());
            Assert.assertEquals(py.value(dt), p.getY(), 4.0e-16 * p.getNorm());
            Assert.assertEquals(pz.value(dt), p.getZ(), 4.0e-16 * p.getNorm());
            Assert.assertEquals(pxDot.value(dt), v.getX(), 9.0e-16 * v.getNorm());
            Assert.assertEquals(pyDot.value(dt), v.getY(), 9.0e-16 * v.getNorm());
            Assert.assertEquals(pzDot.value(dt), v.getZ(), 9.0e-16 * v.getNorm());
            Assert.assertEquals(pxDotDot.value(dt), a.getX(), 1.0e-14 * a.getNorm());
            Assert.assertEquals(pyDotDot.value(dt), a.getY(), 1.0e-14 * a.getNorm());
            Assert.assertEquals(pzDotDot.value(dt), a.getZ(), 1.0e-14 * a.getNorm());
        }

    }

}

From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java

@Test
public void testInterpolatePolynomialPositionOnly() {
    Random random = new Random(0x88740a12e4299003l);
    AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH;
    for (int i = 0; i < 20; ++i) {

        PolynomialFunction px = randomPolynomial(5, random);
        PolynomialFunction py = randomPolynomial(5, random);
        PolynomialFunction pz = randomPolynomial(5, random);
        PolynomialFunction pxDot = px.polynomialDerivative();
        PolynomialFunction pyDot = py.polynomialDerivative();
        PolynomialFunction pzDot = pz.polynomialDerivative();
        PolynomialFunction pxDotDot = pxDot.polynomialDerivative();
        PolynomialFunction pyDotDot = pyDot.polynomialDerivative();
        PolynomialFunction pzDotDot = pzDot.polynomialDerivative();

        List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
        for (double dt : new double[] { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }) {
            Vector3D position = new Vector3D(px.value(dt), py.value(dt), pz.value(dt));
            sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, Vector3D.ZERO, Vector3D.ZERO));
        }//from ww w . j  a va  2  s  .  c om

        for (double dt = 0; dt < 1.0; dt += 0.01) {
            TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt),
                    CartesianDerivativesFilter.USE_P, sample);
            Vector3D p = interpolated.getPosition();
            Vector3D v = interpolated.getVelocity();
            Vector3D a = interpolated.getAcceleration();
            Assert.assertEquals(px.value(dt), p.getX(), 5.0e-16 * p.getNorm());
            Assert.assertEquals(py.value(dt), p.getY(), 5.0e-16 * p.getNorm());
            Assert.assertEquals(pz.value(dt), p.getZ(), 5.0e-16 * p.getNorm());
            Assert.assertEquals(pxDot.value(dt), v.getX(), 7.0e-15 * v.getNorm());
            Assert.assertEquals(pyDot.value(dt), v.getY(), 7.0e-15 * v.getNorm());
            Assert.assertEquals(pzDot.value(dt), v.getZ(), 7.0e-15 * v.getNorm());
            Assert.assertEquals(pxDotDot.value(dt), a.getX(), 2.0e-13 * a.getNorm());
            Assert.assertEquals(pyDotDot.value(dt), a.getY(), 2.0e-13 * a.getNorm());
            Assert.assertEquals(pzDotDot.value(dt), a.getZ(), 2.0e-13 * a.getNorm());
        }

    }
}

From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java

@Test
public void testInterpolateNonPolynomial() {
    AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH;

    List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
    for (double dt : new double[] { 0.0, 0.5, 1.0 }) {
        Vector3D position = new Vector3D(FastMath.cos(dt), FastMath.sin(dt), 0.0);
        Vector3D velocity = new Vector3D(-FastMath.sin(dt), FastMath.cos(dt), 0.0);
        Vector3D acceleration = new Vector3D(-FastMath.cos(dt), -FastMath.sin(dt), 0.0);
        sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, velocity, acceleration));
    }//  w  w w  .  j a v a2s  .  c  o m

    for (double dt = 0; dt < 1.0; dt += 0.01) {
        TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt),
                CartesianDerivativesFilter.USE_PVA, sample);
        Vector3D p = interpolated.getPosition();
        Vector3D v = interpolated.getVelocity();
        Vector3D a = interpolated.getAcceleration();
        Assert.assertEquals(FastMath.cos(dt), p.getX(), 3.0e-10 * p.getNorm());
        Assert.assertEquals(FastMath.sin(dt), p.getY(), 3.0e-10 * p.getNorm());
        Assert.assertEquals(0, p.getZ(), 3.0e-10 * p.getNorm());
        Assert.assertEquals(-FastMath.sin(dt), v.getX(), 3.0e-9 * v.getNorm());
        Assert.assertEquals(FastMath.cos(dt), v.getY(), 3.0e-9 * v.getNorm());
        Assert.assertEquals(0, v.getZ(), 3.0e-9 * v.getNorm());
        Assert.assertEquals(-FastMath.cos(dt), a.getX(), 4.0e-8 * a.getNorm());
        Assert.assertEquals(-FastMath.sin(dt), a.getY(), 4.0e-8 * a.getNorm());
        Assert.assertEquals(0, a.getZ(), 4.0e-8 * a.getNorm());
    }

}

From source file:org.rhwlab.dispim.nucleus.NamedNucleusFile.java

License:asdf

static public RealMatrix rotationMatrix(Vector3D A, Vector3D B) {
    Vector3D a = A.normalize();/*from   ww w  .j a  va 2  s . com*/
    Vector3D b = B.normalize();
    Vector3D v = a.crossProduct(b);

    double s = v.getNormSq();
    double c = a.dotProduct(b);

    RealMatrix vx = MatrixUtils.createRealMatrix(3, 3);
    vx.setEntry(1, 0, v.getZ());
    vx.setEntry(0, 1, -v.getZ());
    vx.setEntry(2, 0, -v.getY());
    vx.setEntry(0, 2, v.getY());
    vx.setEntry(2, 1, v.getX());
    vx.setEntry(1, 2, -v.getX());

    RealMatrix vx2 = vx.multiply(vx);
    RealMatrix scaled = vx2.scalarMultiply((1.0 - c) / s);

    RealMatrix ident = MatrixUtils.createRealIdentityMatrix(3);
    RealMatrix sum = vx.add(scaled);
    RealMatrix ret = ident.add(sum);

    return ret;
}

From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java

public GLSphericalCoordinates(Vector3D v) {
    super(new Vector3D(v.getZ(), v.getX(), v.getY()));
}

From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java

@Override
public Vector3D getCartesian() {
    Vector3D v = super.getCartesian();
    return new Vector3D(v.getY(), v.getZ(), v.getX());
}

From source file:org.surmon.pattern.visualization.math.GLSphericalCoordinates.java

public Vec3 getCartesianGLM() {
    Vector3D v = super.getCartesian();
    return new Vec3((float) v.getY(), (float) v.getZ(), (float) v.getX());
}

From source file:sceneGraph.Rot.java

public DVector applyTo(DVector v) {
    Vector3D result = new Vector3D((double) v.x, (double) v.y, (double) v.z);
    result = rotation.applyTo(result);/* w w w  .j a va  2s. c om*/
    return new DVector((double) result.getX(), (double) result.getY(), (double) result.getZ());
}

From source file:sceneGraph.Rot.java

public DVector getAxis() {
    Vector3D v = rotation.getAxis();
    return new DVector((double) v.getX(), (double) v.getY(), (double) v.getZ());
}

From source file:sceneGraph.Rot.java

public PVector applyTo(PVector v) {
    Vector3D result = new Vector3D((double) v.x, (double) v.y, (double) v.z);
    result = rotation.applyTo(result);/*from ww  w  .ja  v  a  2  s. co m*/
    return new PVector((float) result.getX(), (float) result.getY(), (float) result.getZ());
}