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:fr.cs.examples.frames.Frames2.java

public static void main(String[] args) {
    try {/* w  ww  .j  a  v  a2  s.c  o m*/

        // configure Orekit
        Autoconfiguration.configureOrekit();

        // Considering the following Computing/Measurement date in UTC time scale
        TimeScale utc = TimeScalesFactory.getUTC();
        AbsoluteDate date = new AbsoluteDate(2008, 10, 01, 12, 00, 00.000, utc);

        // The Center of Gravity frame has its origin at the satellite center of gravity (CoG)
        // and its axes parallel to EME2000. It is derived from EME2000 frame at any moment
        // by an unknown transform which depends on the current position and the velocity.
        // Let's initialize this transform by the identity transform.
        UpdatableFrame cogFrame = new UpdatableFrame(FramesFactory.getEME2000(), Transform.IDENTITY, "LOF",
                false);

        // The satellite frame, with origin also at the CoG, depends on attitude.
        // For the sake of this tutorial, we consider a simple inertial attitude here
        Transform cogToSat = new Transform(date, new Rotation(0.6, 0.48, 0, 0.64, false));
        Frame satFrame = new Frame(cogFrame, cogToSat, "sat", false);

        // Finally, the GPS antenna frame can be defined from the satellite frame by 2 transforms:
        // a translation and a rotation
        Transform translateGPS = new Transform(date, new Vector3D(0, 0, 1));
        Transform rotateGPS = new Transform(date, new Rotation(new Vector3D(0, 1, 3), FastMath.toRadians(10)));
        Frame gpsFrame = new Frame(satFrame, new Transform(date, translateGPS, rotateGPS), "GPS", false);

        // Let's get the satellite position and velocity in ITRF as measured by GPS antenna at this moment:
        final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
        final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
        System.out.format(Locale.US, "GPS antenna position in ITRF:    %12.3f %12.3f %12.3f%n", position.getX(),
                position.getY(), position.getZ());
        System.out.format(Locale.US, "GPS antenna velocity in ITRF:    %12.7f %12.7f %12.7f%n", velocity.getX(),
                velocity.getY(), velocity.getZ());

        // The transform from GPS frame to ITRF frame at this moment is defined by
        // a translation and a rotation. The translation is directly provided by the
        // GPS measurement above. The rotation is extracted from the existing tree, where
        // we know all rotations are already up to date, even if one translation is still
        // unknown. We combine the extracted rotation and the measured translation by
        // applying the rotation first because the position/velocity vector are given in
        // ITRF frame not in GPS antenna frame:
        Transform measuredTranslation = new Transform(date, position, velocity);
        Transform formerTransform = gpsFrame
                .getTransformTo(FramesFactory.getITRF(IERSConventions.IERS_2010, true), date);
        Transform preservedRotation = new Transform(date, formerTransform.getRotation(),
                formerTransform.getRotationRate());
        Transform gpsToItrf = new Transform(date, preservedRotation, measuredTranslation);

        // So we can update the transform from EME2000 to CoG frame
        cogFrame.updateTransform(gpsFrame, FramesFactory.getITRF(IERSConventions.IERS_2010, true), gpsToItrf,
                date);

        // And we can get the position and velocity of satellite CoG in EME2000 frame
        PVCoordinates origin = PVCoordinates.ZERO;
        Transform cogToItrf = cogFrame.getTransformTo(FramesFactory.getITRF(IERSConventions.IERS_2010, true),
                date);
        PVCoordinates satItrf = cogToItrf.transformPVCoordinates(origin);
        System.out.format(Locale.US, "Satellite   position in ITRF:    %12.3f %12.3f %12.3f%n",
                satItrf.getPosition().getX(), satItrf.getPosition().getY(), satItrf.getPosition().getZ());
        System.out.format(Locale.US, "Satellite   velocity in ITRF:    %12.7f %12.7f %12.7f%n",
                satItrf.getVelocity().getX(), satItrf.getVelocity().getY(), satItrf.getVelocity().getZ());

        Transform cogToEme2000 = cogFrame.getTransformTo(FramesFactory.getEME2000(), date);
        PVCoordinates satEME2000 = cogToEme2000.transformPVCoordinates(origin);
        System.out.format(Locale.US, "Satellite   position in EME2000: %12.3f %12.3f %12.3f%n",
                satEME2000.getPosition().getX(), satEME2000.getPosition().getY(),
                satEME2000.getPosition().getZ());
        System.out.format(Locale.US, "Satellite   velocity in EME2000: %12.7f %12.7f %12.7f%n",
                satEME2000.getVelocity().getX(), satEME2000.getVelocity().getY(),
                satEME2000.getVelocity().getZ());

    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}

From source file:fr.cs.examples.frames.Frames3.java

public static void main(String[] args) {
    try {// w w w  .  ja  v a2  s.  com

        // configure Orekit and printing format
        Autoconfiguration.configureOrekit();

        // Initial state definition :
        // ==========================

        // Date
        // ****
        AbsoluteDate initialDate = new AbsoluteDate(new DateComponents(1970, 04, 07), TimeComponents.H00,
                TimeScalesFactory.getUTC());

        // Orbit
        // *****
        // The Sun is in the orbital plane for raan ~ 202
        double mu = 3.986004415e+14; // gravitation coefficient
        Frame eme2000 = FramesFactory.getEME2000(); // inertial frame
        Orbit orbit = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.),
                FastMath.toRadians(220.), FastMath.toRadians(5.300), PositionAngle.MEAN, eme2000, initialDate,
                mu);

        // Attitude laws
        // *************

        // Earth
        Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
                Constants.WGS84_EARTH_FLATTENING, earthFrame);

        // Target pointing attitude provider over satellite nadir at date, without yaw compensation
        NadirPointing nadirLaw = new NadirPointing(eme2000, earth);

        // Target pointing attitude provider with yaw compensation
        final PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
        YawSteering yawSteeringLaw = new YawSteering(eme2000, nadirLaw, sun, Vector3D.MINUS_I);

        // Propagator : Eckstein-Hechler analytic propagator
        Propagator propagator = new EcksteinHechlerPropagator(orbit, yawSteeringLaw,
                Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU,
                Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40,
                Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);

        // Let's write the results in a file in order to draw some plots.
        propagator.setMasterMode(10, new OrekitFixedStepHandler() {

            PrintStream out = null;

            public void init(SpacecraftState s0, AbsoluteDate t) throws PropagationException {
                try {
                    File file = new File(System.getProperty("user.home"), "XYZ.dat");
                    System.out.println("Results written to file: " + file.getAbsolutePath());
                    out = new PrintStream(file);
                    out.println("#time X Y Z Wx Wy Wz");
                } catch (IOException ioe) {
                    throw new PropagationException(ioe, LocalizedFormats.SIMPLE_MESSAGE,
                            ioe.getLocalizedMessage());
                }
            }

            public void handleStep(SpacecraftState currentState, boolean isLast) throws PropagationException {
                try {

                    // get the transform from orbit/attitude reference frame to spacecraft frame
                    Transform inertToSpacecraft = currentState.toTransform();

                    // get the position of the Sun in orbit/attitude reference frame
                    Vector3D sunInert = sun.getPVCoordinates(currentState.getDate(), currentState.getFrame())
                            .getPosition();

                    // convert Sun position to spacecraft frame
                    Vector3D sunSat = inertToSpacecraft.transformPosition(sunInert);

                    // and the spacecraft rotational rate also
                    Vector3D spin = inertToSpacecraft.getRotationRate();

                    // Lets calculate the reduced coordinates
                    double sunX = sunSat.getX() / sunSat.getNorm();
                    double sunY = sunSat.getY() / sunSat.getNorm();
                    double sunZ = sunSat.getZ() / sunSat.getNorm();

                    out.format(Locale.US, "%s %12.3f %12.3f %12.3f %12.7f %12.7f %12.7f%n",
                            currentState.getDate(), sunX, sunY, sunZ, spin.getX(), spin.getY(), spin.getZ());

                    if (isLast) {
                        out.close();
                    }
                } catch (OrekitException oe) {
                    throw new PropagationException(oe);
                }
            }

        });

        System.out.println("Running...");
        propagator.propagate(initialDate.shiftedBy(6000));

    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}

From source file:lambertmrev.LambertMRev.java

/**
 * @param args the command line arguments
 */// w w w  . ja  v a2 s  .  c o m
public static void main(String[] args) {
    // Want to test the Lambert class so you can specify the number of revs for which to compute
    //System.out.print("this is the frames tutorial \n");
    try {
        Frame inertialFrame = FramesFactory.getEME2000();
        TimeScale utc = TimeScalesFactory.getTAI();
        AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
        double mu = 3.986004415e+14;

        double a = 24396159; // semi major axis in meters
        double e = 0.72831215; // eccentricity
        double i = Math.toRadians(7); // inclination
        double omega = Math.toRadians(180); // perigee argument
        double raan = Math.toRadians(261); // right ascension of ascending node
        double lM = 0; // mean anomaly

        Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame,
                initialDate, mu);
        //KeplerianPropagator kepler = new KeplerianPropagator(initialOrbit);

        // set geocentric positions
        Vector3D r1 = new Vector3D(-6.88999e3, 3.92763e4, 2.67053e3);
        Vector3D r2 = new Vector3D(-3.41458e4, 2.05328e4, 3.44315e3);
        Vector3D r1_site = new Vector3D(4.72599e3, 1.26633e3, 4.07799e3);
        Vector3D r2_site = new Vector3D(4.70819e3, 1.33099e3, 4.07799e3);

        // get the topocentric positions
        Vector3D top1 = Transform.geo2radec(r1.scalarMultiply(1000), r1_site.scalarMultiply(1000));
        Vector3D top2 = Transform.geo2radec(r2.scalarMultiply(1000), r2_site.scalarMultiply(1000));

        // time of flight in seconds
        double tof = 3 * 3600;

        // propagate to 0 and tof
        Lambert test = new Lambert();

        boolean cw = false;
        int multi_revs = 1;
        RealMatrix v1_mat;
        Random randomGenerator = new Random();

        PrintWriter out_a = new PrintWriter("out_java_a.txt");
        PrintWriter out_e = new PrintWriter("out_java_e.txt");
        PrintWriter out_rho1 = new PrintWriter("out_java_rho1.txt");
        PrintWriter out_rho2 = new PrintWriter("out_java_rho2.txt");

        // start the loop
        double A, Ecc, rho1, rho2, tof_hyp;

        long time1 = System.nanoTime();
        for (int ll = 0; ll < 1e6; ll++) {

            rho1 = top1.getZ() / 1000 + 1e-3 * randomGenerator.nextGaussian() * top1.getZ() / 1000;
            rho2 = top2.getZ() / 1000 + 1e-3 * randomGenerator.nextGaussian() * top2.getZ() / 1000;
            //tof_hyp = FastMath.abs(tof + 0.1*3600 * randomGenerator.nextGaussian());
            // from topo to geo
            Vector3D r1_hyp = Transform.radec2geo(top1.getX(), top1.getY(), rho1, r1_site);
            Vector3D r2_hyp = Transform.radec2geo(top2.getX(), top2.getY(), rho2, r2_site);
            //            System.out.println(r1_hyp.scalarMultiply(1000).getNorm());
            //            System.out.println(r2_hyp.scalarMultiply(1000).getNorm());
            //            System.out.println(tof/3600);
            test.lambert_problem(r1_hyp.scalarMultiply(1000), r2_hyp.scalarMultiply(1000), tof, mu, cw,
                    multi_revs);

            v1_mat = test.get_v1();

            Vector3D v1 = new Vector3D(v1_mat.getEntry(0, 0), v1_mat.getEntry(0, 1), v1_mat.getEntry(0, 2));
            //            System.out.println(v1);
            PVCoordinates rv1 = new PVCoordinates(r1_hyp.scalarMultiply(1000), v1);
            Orbit orbit_out = new KeplerianOrbit(rv1, inertialFrame, initialDate, mu);
            A = orbit_out.getA();
            Ecc = orbit_out.getE();

            //            System.out.println(ll + " - " +A);
            out_a.println(A);
            out_e.println(Ecc);
            out_rho1.println(rho1);
            out_rho2.println(rho2);
        }
        long time2 = System.nanoTime();
        long timeTaken = time2 - time1;

        out_a.close();
        out_e.close();
        out_rho1.close();
        out_rho2.close();

        System.out.println("Time taken " + timeTaken / 1000 / 1000 + " milli secs");

        // get the truth
        test.lambert_problem(r1.scalarMultiply(1000), r2.scalarMultiply(1000), tof, mu, cw, multi_revs);
        v1_mat = test.get_v1();
        Vector3D v1 = new Vector3D(v1_mat.getEntry(0, 0), v1_mat.getEntry(0, 1), v1_mat.getEntry(0, 2));
        PVCoordinates rv1 = new PVCoordinates(r1.scalarMultiply(1000), v1);
        Orbit orbit_out = new KeplerianOrbit(rv1, inertialFrame, initialDate, mu);
        //System.out.println(orbit_out.getA());
    } catch (FileNotFoundException ex) {
        Logger.getLogger(LambertMRev.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Engine.AlgebraUtils.java

public static Vector3D ReturnClosestWectorMirror(Vector3D v1, Vector3D v2, WorldMap worldMap) {
    return ReturnClosestWectorMirror(new double[] { v1.getX(), v1.getY(), v1.getZ() },
            new double[] { v2.getX(), v2.getY(), v2.getZ() }, worldMap);
}

From source file:Satellite.java

public static double[] Convert_To_Lat_Long(Vector3D posVec) {
    double Xcomp = posVec.getX();
    double Ycomp = posVec.getY();
    double Zcomp = posVec.getZ();

    double longitude;
    double latitude;
    double altitude;

    //Done so all cases of longitudes are right
    if (Ycomp > 0) {
        if (Xcomp > 0) {
            longitude = Math.toDegrees(Math.atan(Ycomp / Xcomp));
        } else {//from w  w w  .  j a  va 2  s  .  com
            longitude = 180 - Math.toDegrees(Math.atan(Math.abs(Ycomp / Xcomp)));
        }
    } else {
        if (Xcomp > 0) {
            longitude = -1 * Math.toDegrees(Math.atan(Math.abs(Ycomp / Xcomp)));
        } else {
            longitude = -1 * (180 - Math.toDegrees(Math.atan(Ycomp / Xcomp)));
        }
    }

    //Calculate latitude
    latitude = Math.toDegrees(Math.atan(Zcomp / Math.sqrt(Xcomp * Xcomp + Ycomp * Ycomp)));

    //Calculate radius and altitude
    double EER = Constants.WGS84_EARTH_EQUATORIAL_RADIUS; //Earth Equator Radius in meters
    double EPR = EER - EER * Constants.WGS84_EARTH_FLATTENING; //Earth Polar Radius in meters

    double earthRadius = Math
            .sqrt((Math.pow(EPR * EPR * Math.cos(latitude), 2) + Math.pow(EER * EER * Math.cos(latitude), 2))
                    / (Math.pow(EPR * Math.cos(latitude), 2) + Math.pow(EER * Math.cos(latitude), 2)));
    double orbitRadius = Math.sqrt(Xcomp * Xcomp + Ycomp * Ycomp + Zcomp * Zcomp);
    altitude = orbitRadius - earthRadius;

    return new double[] { latitude, longitude, altitude };
}

From source file:Tester2.java

private static double[] Convert_To_Lat_Long(Vector3D posVec) {
    double Xcomp = posVec.getX();
    double Ycomp = posVec.getY();
    double Zcomp = posVec.getZ();

    double longitude;
    double latitude;
    double altitude;

    //Done so all cases of longitudes are right
    if (Ycomp > 0) {
        if (Xcomp > 0) {
            longitude = FastMath.toDegrees(FastMath.atan(Ycomp / Xcomp));
        } else {//from  w w  w  . j  ava2 s  .  c  o  m
            longitude = 180 - FastMath.toDegrees(FastMath.atan(FastMath.abs(Ycomp / Xcomp)));
        }
    } else {
        if (Xcomp > 0) {
            longitude = -1 * FastMath.toDegrees(FastMath.atan(FastMath.abs(Ycomp / Xcomp)));
        } else {
            longitude = -1 * (180 - FastMath.toDegrees(FastMath.atan(Ycomp / Xcomp)));
        }
    }

    //Calculate latitude
    latitude = FastMath.toDegrees(FastMath.atan(Zcomp / FastMath.sqrt(Xcomp * Xcomp + Ycomp * Ycomp)));

    //Calculate radius and altitude
    double EER = Constants.WGS84_EARTH_EQUATORIAL_RADIUS; //Earth Equator Radius in meters
    double EPR = EER - EER * Constants.WGS84_EARTH_FLATTENING; //Earth Polar Radius in meters

    double earthRadius = FastMath.sqrt((FastMath.pow(EPR * EPR * FastMath.cos(latitude), 2)
            + FastMath.pow(EER * EER * FastMath.cos(latitude), 2))
            / (FastMath.pow(EPR * FastMath.cos(latitude), 2) + FastMath.pow(EER * FastMath.cos(latitude), 2)));
    double orbitRadius = FastMath.sqrt(Xcomp * Xcomp + Ycomp * Ycomp + Zcomp * Zcomp);
    altitude = orbitRadius - earthRadius;

    return new double[] { latitude, longitude, altitude };
}

From source file:edu.mit.fss.examples.visual.gui.WorldWindVisualization.java

/**
 * Converts an Apache Math Commons {@link Vector3D} to a NASA World Wind
 * {@link Vec4}.//from  w  w  w .  j a  v  a  2s. co  m
 *
 * @param vector the Apache Math Commons vector
 * @return the the NASA World Wind vector
 */
private static Vec4 convert(Vector3D vector) {
    return new Vec4(vector.getX(), vector.getY(), vector.getZ());
}

From source file:gentracklets.conversions.java

public static double[] geo2radec(PVCoordinates obj, TopocentricFrame staF, Frame inertialFrame,
        AbsoluteDate epoch) {/*  w w w  . jav  a  2s  .  c  om*/

    Vector3D rho = new Vector3D(0, 0, 0);

    try {
        rho = obj.getPosition().subtract(staF.getPVCoordinates(epoch, inertialFrame).getPosition());
    } catch (OrekitException ex) {
        Logger.getLogger(conversions.class.getName()).log(Level.SEVERE, null, ex);
    }

    double rho_mag = rho.getNorm();
    double DEC = FastMath.asin(rho.getZ() / rho_mag);
    double cosRA = 0.0;
    double sinRA = 0.0;
    double RA = 0.0;

    Vector3D v_site = new Vector3D(0, 0, 0);
    try {
        v_site = staF.getPVCoordinates(epoch, inertialFrame).getVelocity();
    } catch (OrekitException ex) {
        Logger.getLogger(conversions.class.getName()).log(Level.SEVERE, null, ex);
    }

    Vector3D rhoDot = obj.getVelocity().subtract(v_site);

    if (FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2)) != 0) {
        cosRA = rho.getX() / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));
        sinRA = rho.getY() / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));
        RA = FastMath.atan2(sinRA, cosRA);
        if (RA <= 0) {
            RA = RA + 2 * FastMath.PI;
        }
    } else {
        sinRA = rhoDot.getY() / FastMath.sqrt(FastMath.pow(rhoDot.getX(), 2) + FastMath.pow(rhoDot.getY(), 2));
        cosRA = rhoDot.getX() / FastMath.sqrt(FastMath.pow(rhoDot.getX(), 2) + FastMath.pow(rhoDot.getY(), 2));
        RA = FastMath.atan2(sinRA, cosRA);
        if (RA <= 0) {
            RA = RA + 2 * FastMath.PI;
        }
    }

    double rhoDot_mag = rho.dotProduct(rhoDot) / rho_mag;
    double RAdot = (rhoDot.getX() * rho.getY() - rhoDot.getY() * rho.getX())
            / (-1 * FastMath.pow(rho.getY(), 2) - FastMath.pow(rho.getX(), 2));
    double DECdot = (rhoDot.getZ() - rhoDot_mag * FastMath.sin(DEC))
            / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));

    double[] out = { RA, RAdot, DEC, DECdot, rho_mag, rhoDot_mag };

    return out;
}

From source file:jtrace.object.transformation.Scale.java

@Override
public Vector3D apply(Vector3D vec) {
    return new Vector3D(vec.getX() * scaleVec.getX(), vec.getY() * scaleVec.getY(),
            vec.getZ() * scaleVec.getZ());
}

From source file:jtrace.object.transformation.Scale.java

@Override
public Vector3D applyInverse(Vector3D vec) {
    return new Vector3D(vec.getX() / scaleVec.getX(), vec.getY() / scaleVec.getY(),
            vec.getZ() / scaleVec.getZ());
}