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 x, double y, double z) 

Source Link

Document

Simple constructor.

Usage

From source file:org.orekit.bodies.OneAxisEllipsoidTest.java

@Test
public void testNegativeZ() throws OrekitException {
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid model = new OneAxisEllipsoid(90.0, 5.0 / 9.0, frame);
    Vector3D point = new Vector3D(140.0, 0.0, -30.0);
    GeodeticPoint gp = model.transform(point, frame, date);
    Vector3D rebuilt = model.transform(gp);
    Assert.assertEquals(0.0, rebuilt.distance(point), 1.0e-10);
}

From source file:org.orekit.bodies.OneAxisEllipsoidTest.java

@Test
public void testEquatorialInside() throws OrekitException {
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid model = new OneAxisEllipsoid(90.0, 5.0 / 9.0, frame);
    for (double rho = 0; rho < model.getEquatorialRadius(); rho += 0.01) {
        Vector3D point = new Vector3D(rho, 0.0, 0.0);
        GeodeticPoint gp = model.transform(point, frame, date);
        Vector3D rebuilt = model.transform(gp);
        Assert.assertEquals(0.0, rebuilt.distance(point), 1.0e-10);
    }//from w ww . j  a  v a 2 s  .c  o m
}

From source file:org.orekit.bodies.OneAxisEllipsoidTest.java

@Test
public void testFarPoint() throws OrekitException {
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid model = new OneAxisEllipsoid(90.0, 5.0 / 9.0, frame);
    Vector3D point = new Vector3D(1.0e15, 2.0e15, -1.0e12);
    GeodeticPoint gp = model.transform(point, frame, date);
    Vector3D rebuilt = model.transform(gp);
    Assert.assertEquals(0.0, rebuilt.distance(point), 1.0e-15 * point.getNorm());
}

From source file:org.orekit.bodies.OneAxisEllipsoidTest.java

@Test
public void testIssue141() throws OrekitException {
    AbsoluteDate date = new AbsoluteDate("2002-03-06T20:50:20.44188731559965033", TimeScalesFactory.getUTC());
    Frame frame = FramesFactory.getGTOD(IERSConventions.IERS_1996, true);
    OneAxisEllipsoid model = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
            Constants.WGS84_EARTH_FLATTENING, frame);
    Vector3D point = new Vector3D(-6838696.282102453, -2148321.403361013, -0.011907944179711194);
    GeodeticPoint gp = model.transform(point, frame, date);
    Vector3D rebuilt = model.transform(gp);
    Assert.assertEquals(0.0, rebuilt.distance(point), 1.0e-15 * point.getNorm());
}

From source file:org.orekit.bodies.OneAxisEllipsoidTest.java

private void checkCartesianToEllipsoidic(double ae, double f, double x, double y, double z, double longitude,
        double latitude, double altitude) throws OrekitException {

    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid model = new OneAxisEllipsoid(ae, f, frame);
    GeodeticPoint gp = model.transform(new Vector3D(x, y, z), frame, date);
    Assert.assertEquals(longitude, MathUtils.normalizeAngle(gp.getLongitude(), longitude), 1.0e-10);
    Assert.assertEquals(latitude, gp.getLatitude(), 1.0e-10);
    Assert.assertEquals(altitude, gp.getAltitude(), 1.0e-10 * FastMath.abs(ae));
    Vector3D rebuiltNadir = Vector3D.crossProduct(gp.getSouth(), gp.getWest());
    Assert.assertEquals(0, rebuiltNadir.subtract(gp.getNadir()).getNorm(), 1.0e-15);
}

From source file:org.orekit.bodies.PosVelChebyshev.java

/** Get the position-velocity-acceleration at a specified date.
 * @param date date at which position-velocity-acceleration is requested
 * @return position-velocity-acceleration at specified date
 *//*from  w w w. ja  va 2s. c  om*/
public PVCoordinates getPositionVelocityAcceleration(final AbsoluteDate date) {

    // normalize date
    final double t = (2 * date.durationFrom(start) - duration) / duration;
    final double twoT = 2 * t;

    // initialize Chebyshev polynomials recursion
    double pKm1 = 1;
    double pK = t;
    double xP = xCoeffs[0];
    double yP = yCoeffs[0];
    double zP = zCoeffs[0];

    // initialize Chebyshev polynomials derivatives recursion
    double qKm1 = 0;
    double qK = 1;
    double xV = 0;
    double yV = 0;
    double zV = 0;

    // initialize Chebyshev polynomials second derivatives recursion
    double rKm1 = 0;
    double rK = 0;
    double xA = 0;
    double yA = 0;
    double zA = 0;

    // combine polynomials by applying coefficients
    for (int k = 1; k < xCoeffs.length; ++k) {

        // consider last computed polynomials on position
        xP += xCoeffs[k] * pK;
        yP += yCoeffs[k] * pK;
        zP += zCoeffs[k] * pK;

        // consider last computed polynomials on velocity
        xV += xCoeffs[k] * qK;
        yV += yCoeffs[k] * qK;
        zV += zCoeffs[k] * qK;

        // consider last computed polynomials on acceleration
        xA += xCoeffs[k] * rK;
        yA += yCoeffs[k] * rK;
        zA += zCoeffs[k] * rK;

        // compute next Chebyshev polynomial value
        final double pKm2 = pKm1;
        pKm1 = pK;
        pK = twoT * pKm1 - pKm2;

        // compute next Chebyshev polynomial derivative
        final double qKm2 = qKm1;
        qKm1 = qK;
        qK = twoT * qKm1 + 2 * pKm1 - qKm2;

        // compute next Chebyshev polynomial second derivative
        final double rKm2 = rKm1;
        rKm1 = rK;
        rK = twoT * rKm1 + 4 * qKm1 - rKm2;

    }

    final double vScale = 2 / duration;
    final double aScale = vScale * vScale;
    return new PVCoordinates(new Vector3D(xP, yP, zP), new Vector3D(xV * vScale, yV * vScale, zV * vScale),
            new Vector3D(xA * aScale, yA * aScale, zA * aScale));

}

From source file:org.orekit.bodies.SolarBodyTest.java

@Test
public void geocentricPV() throws OrekitException, ParseException {
    Utils.setDataRoot("regular-data");
    AbsoluteDate date = new AbsoluteDate(1969, 06, 25, TimeScalesFactory.getTDB());
    Frame geocentricFrame = FramesFactory.getGCRF();
    checkPV(CelestialBodyFactory.getMoon(), date, geocentricFrame,
            new Vector3D(-0.0022350411591597575, -0.0010106334699928434, -5.658291803646671E-4),
            new Vector3D(3.1279236468844985E-4, -4.526815459166321E-4, -2.428841016970333E-4));
    checkPV(CelestialBodyFactory.getEarth(), date, geocentricFrame, Vector3D.ZERO, Vector3D.ZERO);
}

From source file:org.orekit.bodies.SolarBodyTest.java

@Test
public void heliocentricPV() throws OrekitException, ParseException {
    Utils.setDataRoot("regular-data");
    AbsoluteDate date = new AbsoluteDate(1969, 06, 25, TimeScalesFactory.getTDB());
    final Frame gcrf = FramesFactory.getGCRF();
    Frame heliocentricFrame = new Frame(gcrf, new TransformProvider() {
        private static final long serialVersionUID = 1L;

        public Transform getTransform(AbsoluteDate date) throws OrekitException {
            return new Transform(date, CelestialBodyFactory.getSun().getPVCoordinates(date, gcrf).negate());
        }//ww  w  .j  a  va  2 s  . c o  m
    }, "heliocentric/aligned GCRF", true);
    checkPV(CelestialBodyFactory.getSun(), date, heliocentricFrame, Vector3D.ZERO, Vector3D.ZERO);
    checkPV(CelestialBodyFactory.getMercury(), date, heliocentricFrame,
            new Vector3D(0.3388866970713254, -0.16350851403469605, -0.12250815624343761),
            new Vector3D(0.008716751907934464, 0.02294287010530833, 0.011349219084264612));
    checkPV(CelestialBodyFactory.getVenus(), date, heliocentricFrame,
            new Vector3D(0.5733328682513444, -0.3947124128748959, -0.21383496742544283),
            new Vector3D(0.012311818929592546, 0.014756722625966128, 0.005857890214695866));
    checkPV(CelestialBodyFactory.getMars(), date, heliocentricFrame,
            new Vector3D(-0.15808000178306866, -1.3285167111540124, -0.6050478023304016),
            new Vector3D(0.014443621048367267, -1.3669889027283553E-4, -4.542404441793112E-4));
    checkPV(CelestialBodyFactory.getJupiter(), date, heliocentricFrame,
            new Vector3D(-5.387442227958154, -0.8116709870422928, -0.21662388956102652),
            new Vector3D(0.0010628473875341506, -0.006527800816267844, -0.0028242250304474767));
    checkPV(CelestialBodyFactory.getSaturn(), date, heliocentricFrame,
            new Vector3D(7.89952834654684, 4.582711147265509, 1.552649660593234),
            new Vector3D(-0.003208403682518813, 0.004335751536569781, 0.001928152129122073));
    checkPV(CelestialBodyFactory.getUranus(), date, heliocentricFrame,
            new Vector3D(-18.2705614311796, -1.151408356279009, -0.24540975062356502),
            new Vector3D(2.1887052624725852E-4, -0.0037678288699642877, -0.0016532828516810242));
    checkPV(CelestialBodyFactory.getNeptune(), date, heliocentricFrame,
            new Vector3D(-16.06747366050193, -23.938436657940095, -9.39837851302005),
            new Vector3D(0.0026425894813251684, -0.0015042632480101307, -6.815738977894145E-4));
    checkPV(CelestialBodyFactory.getPluto(), date, heliocentricFrame,
            new Vector3D(-30.488788499360652, -0.8637991387172488, 8.914537151982762),
            new Vector3D(3.21695873843002E-4, -0.0031487797507673814, -0.0010799339515148705));
}

From source file:org.orekit.files.ccsds.OEMParser.java

/**
 * Parse an ephemeris data line and add its content to the ephemerides
 * block./*from w w  w .ja v a 2 s.  co  m*/
 *
 * @param reader the reader
 * @param pi the parser info
 * @exception IOException if an error occurs while reading from the stream
 * @exception OrekitException if a date cannot be parsed
 */
private void parseEphemeridesDataLines(final BufferedReader reader, final ParseInfo pi)
        throws OrekitException, IOException {

    for (String line = reader.readLine(); line != null; line = reader.readLine()) {

        ++pi.lineNumber;
        if (line.trim().length() > 0) {
            pi.keyValue = new KeyValue(line, pi.lineNumber, pi.fileName);
            if (pi.keyValue.getKeyword() == null) {
                Scanner sc = null;
                try {
                    sc = new Scanner(line);
                    final AbsoluteDate date = parseDate(sc.next(),
                            pi.lastEphemeridesBlock.getMetaData().getTimeSystem());
                    final Vector3D position = new Vector3D(Double.parseDouble(sc.next()) * 1000,
                            Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000);
                    final Vector3D velocity = new Vector3D(Double.parseDouble(sc.next()) * 1000,
                            Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000);
                    final CartesianOrbit orbit = new CartesianOrbit(new PVCoordinates(position, velocity),
                            pi.lastEphemeridesBlock.getMetaData().getFrame(), date, pi.file.getMuUsed());
                    Vector3D acceleration = null;
                    if (sc.hasNext()) {
                        acceleration = new Vector3D(Double.parseDouble(sc.next()) * 1000,
                                Double.parseDouble(sc.next()) * 1000, Double.parseDouble(sc.next()) * 1000);
                    }
                    final OEMFile.EphemeridesDataLine epDataLine = new OEMFile.EphemeridesDataLine(orbit,
                            acceleration);
                    pi.lastEphemeridesBlock.getEphemeridesDataLines().add(epDataLine);
                } catch (NumberFormatException nfe) {
                    throw new OrekitException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, pi.lineNumber,
                            pi.fileName, line);
                } finally {
                    if (sc != null) {
                        sc.close();
                    }
                }
            } else {
                switch (pi.keyValue.getKeyword()) {
                case META_START:
                    pi.lastEphemeridesBlock.setEphemeridesDataLinesComment(pi.commentTmp);
                    pi.commentTmp.clear();
                    pi.lineNumber--;
                    reader.reset();
                    return;
                case COVARIANCE_START:
                    pi.lastEphemeridesBlock.setEphemeridesDataLinesComment(pi.commentTmp);
                    pi.commentTmp.clear();
                    pi.lineNumber--;
                    reader.reset();
                    return;
                case COMMENT:
                    pi.commentTmp.add(pi.keyValue.getValue());
                    break;
                default:
                    throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber,
                            pi.fileName, line);
                }
            }
        }
        reader.mark(300);

    }
}

From source file:org.orekit.files.ccsds.OEMParserTest.java

@Test
public void testParseOEM1() throws OrekitException, IOException {
    ///*  w  w w  .j a  v a  2 s.  c  o m*/
    final String ex = "/ccsds/OEMExample.txt";
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM());
    final OEMFile file = parser.parse(inEntry, "OEMExample.txt");
    Assert.assertEquals(TimeSystem.UTC, file.getTimeSystem());
    Assert.assertEquals("MARS GLOBAL SURVEYOR",
            file.getEphemeridesBlocks().get(0).getMetaData().getObjectName());
    Assert.assertEquals("1996-062A", file.getEphemeridesBlocks().get(0).getMetaData().getObjectID());
    Assert.assertEquals("MARS BARYCENTER", file.getEphemeridesBlocks().get(0).getMetaData().getCenterName());
    Assert.assertEquals(1996, file.getEphemeridesBlocks().get(0).getMetaData().getLaunchYear());
    Assert.assertEquals(62, file.getEphemeridesBlocks().get(0).getMetaData().getLaunchNumber());
    Assert.assertEquals("A", file.getEphemeridesBlocks().get(0).getMetaData().getLaunchPiece());
    Assert.assertFalse(file.getEphemeridesBlocks().get(0).getMetaData().getHasCreatableBody());
    Assert.assertNull(file.getEphemeridesBlocks().get(0).getMetaData().getCenterBody());
    Assert.assertEquals(new AbsoluteDate(1996, 12, 18, 12, 00, 0.331, TimeScalesFactory.getUTC()),
            file.getEphemeridesBlocks().get(0).getStartTime());
    Assert.assertEquals(new AbsoluteDate(1996, 12, 28, 21, 28, 0.331, TimeScalesFactory.getUTC()),
            file.getEphemeridesBlocks().get(0).getStopTime());
    Assert.assertEquals(new AbsoluteDate(1996, 12, 18, 12, 10, 0.331, TimeScalesFactory.getUTC()),
            file.getEphemeridesBlocks().get(0).getUseableStartTime());
    Assert.assertEquals(new AbsoluteDate(1996, 12, 28, 21, 23, 0.331, TimeScalesFactory.getUTC()),
            file.getEphemeridesBlocks().get(0).getUseableStopTime());
    Assert.assertEquals("HERMITE", file.getEphemeridesBlocks().get(0).getInterpolationMethod());
    Assert.assertEquals(7, file.getEphemeridesBlocks().get(0).getInterpolationDegree());
    ArrayList<String> ephemeridesDataLinesComment = new ArrayList<String>();
    ephemeridesDataLinesComment.add("This file was produced by M.R. Somebody, MSOO NAV/JPL, 1996NOV 04. It is");
    ephemeridesDataLinesComment.add("to be used for DSN scheduling purposes only.");
    Assert.assertEquals(ephemeridesDataLinesComment,
            file.getEphemeridesBlocks().get(0).getEphemeridesDataLinesComment());
    CartesianOrbit orbit = new CartesianOrbit(
            new PVCoordinates(new Vector3D(2789.619 * 1000, -280.045 * 1000, -1746.755 * 1000),
                    new Vector3D(4.73372 * 1000, -2.49586 * 1000, -1.04195 * 1000)),
            FramesFactory.getEME2000(), new AbsoluteDate("1996-12-18T12:00:00.331", TimeScalesFactory.getUTC()),
            CelestialBodyFactory.getEarth().getGM());
    Assert.assertArrayEquals(
            orbit.getPVCoordinates().getPosition().toArray(), file.getEphemeridesBlocks().get(0)
                    .getEphemeridesDataLines().get(0).getOrbit().getPVCoordinates().getPosition().toArray(),
            1e-10);
    Assert.assertArrayEquals(
            orbit.getPVCoordinates().getVelocity().toArray(), file.getEphemeridesBlocks().get(0)
                    .getEphemeridesDataLines().get(0).getOrbit().getPVCoordinates().getVelocity().toArray(),
            1e-10);
    Assert.assertArrayEquals((new Vector3D(1, 1, 1)).toArray(),
            file.getEphemeridesBlocks().get(1).getEphemeridesDataLines().get(0).getAcceleration().toArray(),
            1e-10);
    final Array2DRowRealMatrix covMatrix = new Array2DRowRealMatrix(6, 6);
    final double[] column1 = { 3.331349476038534e-04, 4.618927349220216e-04, -3.070007847730449e-04,
            -3.349365033922630e-07, -2.211832501084875e-07, -3.041346050686871e-07 };
    final double[] column2 = { 4.618927349220216e-04, 6.782421679971363e-04, -4.221234189514228e-04,
            -4.686084221046758e-07, -2.864186892102733e-07, -4.989496988610662e-07 };
    final double[] column3 = { -3.070007847730449e-04, -4.221234189514228e-04, 3.231931992380369e-04,
            2.484949578400095e-07, 1.798098699846038e-07, 3.540310904497689e-07 };
    final double[] column4 = { -3.349365033922630e-07, -4.686084221046758e-07, 2.484949578400095e-07,
            4.296022805587290e-10, 2.608899201686016e-10, 1.869263192954590e-10 };
    final double[] column5 = { -2.211832501084875e-07, -2.864186892102733e-07, 1.798098699846038e-07,
            2.608899201686016e-10, 1.767514756338532e-10, 1.008862586240695e-10 };
    final double[] column6 = { -3.041346050686871e-07, -4.989496988610662e-07, 3.540310904497689e-07,
            1.869263192954590e-10, 1.008862586240695e-10, 6.224444338635500e-10 };
    covMatrix.setColumn(0, column1);
    covMatrix.setColumn(1, column2);
    covMatrix.setColumn(2, column3);
    covMatrix.setColumn(3, column4);
    covMatrix.setColumn(4, column5);
    covMatrix.setColumn(5, column6);
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 6; j++) {
            Assert.assertEquals(covMatrix.getEntry(i, j), file.getEphemeridesBlocks().get(2)
                    .getCovarianceMatrices().get(0).getMatrix().getEntry(i, j), 1e-10);
        }
    }
    Assert.assertEquals(new AbsoluteDate("1996-12-28T21:29:07.267", TimeScalesFactory.getUTC()),
            file.getEphemeridesBlocks().get(2).getCovarianceMatrices().get(0).getEpoch());
    Assert.assertEquals(FramesFactory.getEME2000(),
            file.getEphemeridesBlocks().get(2).getCovarianceMatrices().get(1).getFrame());
}