List of usage examples for org.apache.commons.math3.util FastMath toRadians
public static double toRadians(double x)
From source file:fr.cs.examples.propagation.SlaveMode.java
/** Program entry point. * @param args program arguments (unused here) *//*from w ww. j a v a2s .com*/ public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); // Initial orbit parameters double a = 24396159; // semi major axis in meters double e = 0.72831215; // eccentricity double i = FastMath.toRadians(7); // inclination double omega = FastMath.toRadians(180); // perigee argument double raan = FastMath.toRadians(261); // right ascension of ascending node double lM = 0; // mean anomaly // Inertial frame Frame inertialFrame = FramesFactory.getEME2000(); // Initial date in UTC time scale TimeScale utc = TimeScalesFactory.getUTC(); AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc); // gravitation coefficient double mu = 3.986004415e+14; // Orbit construction as Keplerian Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu); // Simple extrapolation with Keplerian motion KeplerianPropagator kepler = new KeplerianPropagator(initialOrbit); // Set the propagator to slave mode (could be omitted as it is the default mode) kepler.setSlaveMode(); // Overall duration in seconds for extrapolation double duration = 600.; // Stop date final AbsoluteDate finalDate = initialDate.shiftedBy(duration); // Step duration in seconds double stepT = 60.; // Extrapolation loop int cpt = 1; for (AbsoluteDate extrapDate = initialDate; extrapDate .compareTo(finalDate) <= 0; extrapDate = extrapDate.shiftedBy(stepT)) { SpacecraftState currentState = kepler.propagate(extrapDate); System.out.println("step " + cpt++); System.out.println(" time : " + currentState.getDate()); System.out.println(" " + currentState.getOrbit()); } } catch (OrekitException oe) { System.err.println(oe.getMessage()); } }
From source file:fr.cs.examples.propagation.EphemerisMode.java
/** Program entry point. * @param args program arguments (unused here) *//*from ww w . jav a 2s. co m*/ public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); // Initial orbit parameters double a = 24396159; // semi major axis in meters double e = 0.72831215; // eccentricity double i = FastMath.toRadians(7); // inclination double omega = FastMath.toRadians(180); // perigee argument double raan = FastMath.toRadians(261); // right ascension of ascending node double lM = 0; // mean anomaly // Inertial frame Frame inertialFrame = FramesFactory.getEME2000(); // Initial date in UTC time scale TimeScale utc = TimeScalesFactory.getUTC(); AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc); // gravitation coefficient double mu = 3.986004415e+14; // Orbit construction as Keplerian Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu); // Initialize state SpacecraftState initialState = new SpacecraftState(initialOrbit); // Numerical propagation with no perturbation (only keplerian movement) // Using a very simple integrator with a fixed step: classical Runge-Kutta double stepSize = 10; // the step is ten seconds AbstractIntegrator integrator = new ClassicalRungeKuttaIntegrator(stepSize); NumericalPropagator propagator = new NumericalPropagator(integrator); // Set the propagator to ephemeris mode propagator.setEphemerisMode(); // Initialize propagation propagator.setInitialState(initialState); // Propagation with storage of the results in an integrated ephemeris SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(6000)); System.out.println(" Numerical propagation :"); System.out.println(" Final date : " + finalState.getDate()); System.out.println(" " + finalState.getOrbit()); // Getting the integrated ephemeris BoundedPropagator ephemeris = propagator.getGeneratedEphemeris(); System.out .println(" Ephemeris defined from " + ephemeris.getMinDate() + " to " + ephemeris.getMaxDate()); System.out.println(" Ephemeris propagation :"); AbsoluteDate intermediateDate = initialDate.shiftedBy(3000); SpacecraftState intermediateState = ephemeris.propagate(intermediateDate); System.out.println(" date : " + intermediateState.getDate()); System.out.println(" " + intermediateState.getOrbit()); intermediateDate = finalState.getDate(); intermediateState = ephemeris.propagate(intermediateDate); System.out.println(" date : " + intermediateState.getDate()); System.out.println(" " + intermediateState.getOrbit()); intermediateDate = initialDate.shiftedBy(-1000); System.out.println(); System.out.println("Attempting to propagate to date " + intermediateDate + " which is OUT OF RANGE"); System.out.println("This propagation attempt should fail, " + "so an error message shoud appear below, " + "this is expected and shows that errors are handled correctly"); intermediateState = ephemeris.propagate(intermediateDate); // these two print should never happen as en exception should have been triggered System.out.println(" date : " + intermediateState.getDate()); System.out.println(" " + intermediateState.getOrbit()); } catch (OrekitException oe) { System.out.println(oe.getMessage()); } }
From source file:fr.cs.examples.propagation.MasterMode.java
/** Program entry point. * @param args program arguments (unused here) *//*w w w.j a v a 2s .co m*/ public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); // gravitation coefficient double mu = 3.986004415e+14; // inertial frame Frame inertialFrame = FramesFactory.getEME2000(); // Initial date AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC()); // Initial orbit double a = 24396159; // semi major axis in meters double e = 0.72831215; // eccentricity double i = FastMath.toRadians(7); // inclination double omega = FastMath.toRadians(180); // perigee argument double raan = FastMath.toRadians(261); // right ascention of ascending node double lM = 0; // mean anomaly Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu); // Initial state definition SpacecraftState initialState = new SpacecraftState(initialOrbit); // Adaptive step integrator with a minimum step of 0.001 and a maximum step of 1000 final double minStep = 0.001; final double maxstep = 1000.0; final double positionTolerance = 10.0; final OrbitType propagationType = OrbitType.KEPLERIAN; final double[][] tolerances = NumericalPropagator.tolerances(positionTolerance, initialOrbit, propagationType); AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxstep, tolerances[0], tolerances[1]); // Propagator NumericalPropagator propagator = new NumericalPropagator(integrator); propagator.setOrbitType(propagationType); // Force Model (reduced to perturbing gravity field) final NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(10, 10); ForceModel holmesFeatherstone = new HolmesFeatherstoneAttractionModel( FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider); // Add force model to the propagator propagator.addForceModel(holmesFeatherstone); // Set up initial state in the propagator propagator.setInitialState(initialState); // Set up operating mode for the propagator as master mode // with fixed step and specialized step handler propagator.setMasterMode(60., new TutorialStepHandler()); // Extrapolate from the initial to the final date SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(630.)); KeplerianOrbit o = (KeplerianOrbit) OrbitType.KEPLERIAN.convertType(finalState.getOrbit()); System.out.format(Locale.US, "Final state:%n%s %12.3f %10.8f %10.6f %10.6f %10.6f %10.6f%n", finalState.getDate(), o.getA(), o.getE(), FastMath.toDegrees(o.getI()), FastMath.toDegrees(o.getPerigeeArgument()), FastMath.toDegrees(o.getRightAscensionOfAscendingNode()), FastMath.toDegrees(o.getTrueAnomaly())); } 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 ww. j av a 2 s . c o m // 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:fr.cs.examples.frames.Frames2.java
public static void main(String[] args) { try {/*w w w . j av a 2 s. co 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.Frames1.java
public static void main(String[] args) { try {// w w w . j av a 2 s .c o m // configure Orekit Autoconfiguration.configureOrekit(); // Initial state definition : date, orbit TimeScale utc = TimeScalesFactory.getUTC(); AbsoluteDate initialDate = new AbsoluteDate(2008, 10, 01, 0, 0, 00.000, utc); double mu = 3.986004415e+14; // gravitation coefficient Frame inertialFrame = FramesFactory.getEME2000(); // inertial frame for orbit definition Vector3D posisat = new Vector3D(-6142438.668, 3492467.560, -25767.25680); Vector3D velosat = new Vector3D(505.8479685, 942.7809215, 7435.922231); PVCoordinates pvsat = new PVCoordinates(posisat, velosat); Orbit initialOrbit = new CartesianOrbit(pvsat, inertialFrame, initialDate, mu); // Propagator : consider a simple keplerian motion Propagator kepler = new KeplerianPropagator(initialOrbit); // The local orbital frame (LOF) is related to the orbit propagated by the kepler propagator. LocalOrbitalFrame lof = new LocalOrbitalFrame(inertialFrame, LOFType.QSW, kepler, "QSW"); // Earth and frame Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true); BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame); // Station final double longitude = FastMath.toRadians(45.); final double latitude = FastMath.toRadians(25.); final double altitude = 0.; final GeodeticPoint station = new GeodeticPoint(latitude, longitude, altitude); final TopocentricFrame staF = new TopocentricFrame(earth, station, "station"); System.out.println(" time doppler (m/s)"); // Stop date final AbsoluteDate finalDate = new AbsoluteDate(initialDate, 6000, utc); // Loop AbsoluteDate extrapDate = initialDate; while (extrapDate.compareTo(finalDate) <= 0) { // We can simply get the position and velocity of station in LOF frame at any time PVCoordinates pv = staF.getTransformTo(lof, extrapDate).transformPVCoordinates(PVCoordinates.ZERO); // And then calculate the doppler signal double doppler = Vector3D.dotProduct(pv.getPosition(), pv.getVelocity()) / pv.getPosition().getNorm(); System.out.format(Locale.US, "%s %9.3f%n", extrapDate, doppler); extrapDate = new AbsoluteDate(extrapDate, 600, utc); } } catch (OrekitException oe) { System.err.println(oe.getMessage()); } }
From source file:fr.cs.examples.propagation.VisibilityCheck.java
/** Program entry point. * @param args program arguments (unused here) *//*from w ww . j av a 2 s . com*/ public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); // Initial state definition : date, orbit AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC()); double mu = 3.986004415e+14; // gravitation coefficient Frame inertialFrame = FramesFactory.getEME2000(); // inertial frame for orbit definition Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680); Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231); PVCoordinates pvCoordinates = new PVCoordinates(position, velocity); Orbit initialOrbit = new KeplerianOrbit(pvCoordinates, inertialFrame, initialDate, mu); // Propagator : consider a simple keplerian motion (could be more elaborate) Propagator kepler = new KeplerianPropagator(initialOrbit); // Earth and frame Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true); BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame); // Station final double longitude = FastMath.toRadians(45.); final double latitude = FastMath.toRadians(25.); final double altitude = 0.; final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude); final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1"); // Event definition final double maxcheck = 60.0; final double threshold = 0.001; final double elevation = FastMath.toRadians(5.0); final EventDetector sta1Visi = new ElevationDetector(maxcheck, threshold, sta1Frame) .withConstantElevation(elevation).withHandler(new VisibilityHandler()); // Add event to be detected kepler.addEventDetector(sta1Visi); // Propagate from the initial date to the first raising or for the fixed duration SpacecraftState finalState = kepler.propagate(initialDate.shiftedBy(1500.)); System.out.println(" Final state : " + finalState.getDate().durationFrom(initialDate)); } catch (OrekitException oe) { System.err.println(oe.getMessage()); } }
From source file:fr.cs.examples.conversion.PropagatorConversion.java
/** Program entry point. * @param args program arguments (unused here) *//*from www .java 2 s . c om*/ public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); // gravity field NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(2, 0); double mu = provider.getMu(); // inertial frame Frame inertialFrame = FramesFactory.getEME2000(); // Initial date AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC()); // Initial orbit (GTO) final double a = 24396159; // semi major axis in meters final double e = 0.72831215; // eccentricity final double i = FastMath.toRadians(7); // inclination final double omega = FastMath.toRadians(180); // perigee argument final double raan = FastMath.toRadians(261); // right ascention of ascending node final double lM = 0; // mean anomaly Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu); final double period = initialOrbit.getKeplerianPeriod(); // Initial state definition final SpacecraftState initialState = new SpacecraftState(initialOrbit); // Adaptive step integrator with a minimum step of 0.001 and a maximum step of 1000 final double minStep = 0.001; final double maxStep = 1000.; final double dP = 1.e-2; final OrbitType orbType = OrbitType.CARTESIAN; final double[][] tol = NumericalPropagator.tolerances(dP, initialOrbit, orbType); final AbstractIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tol[0], tol[1]); // Propagator NumericalPropagator numProp = new NumericalPropagator(integrator); numProp.setInitialState(initialState); numProp.setOrbitType(orbType); // Force Models: // 1 - Perturbing gravity field (only J2 is considered here) ForceModel gravity = new HolmesFeatherstoneAttractionModel( FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider); // Add force models to the propagator numProp.addForceModel(gravity); // Propagator factory PropagatorBuilder builder = new KeplerianPropagatorBuilder(mu, inertialFrame, OrbitType.KEPLERIAN, PositionAngle.TRUE); // Propagator converter PropagatorConverter fitter = new FiniteDifferencePropagatorConverter(builder, 1.e-6, 5000); // Resulting propagator KeplerianPropagator kepProp = (KeplerianPropagator) fitter.convert(numProp, 2 * period, 251); // Step handlers StatesHandler numStepHandler = new StatesHandler(); StatesHandler kepStepHandler = new StatesHandler(); // Set up operating mode for the propagator as master mode // with fixed step and specialized step handler numProp.setMasterMode(60., numStepHandler); kepProp.setMasterMode(60., kepStepHandler); // Extrapolate from the initial to the final date numProp.propagate(initialDate.shiftedBy(10. * period)); kepProp.propagate(initialDate.shiftedBy(10. * period)); // retrieve the states List<SpacecraftState> numStates = numStepHandler.getStates(); List<SpacecraftState> kepStates = kepStepHandler.getStates(); // Print the results on the output file File output = new File(new File(System.getProperty("user.home")), "elements.dat"); PrintStream stream = new PrintStream(output); stream.println("# date Anum Akep Enum Ekep Inum Ikep LMnum LMkep"); for (SpacecraftState numState : numStates) { for (SpacecraftState kepState : kepStates) { if (numState.getDate().compareTo(kepState.getDate()) == 0) { stream.println(numState.getDate() + " " + numState.getA() + " " + kepState.getA() + " " + numState.getE() + " " + kepState.getE() + " " + FastMath.toDegrees(numState.getI()) + " " + FastMath.toDegrees(kepState.getI()) + " " + FastMath.toDegrees(MathUtils.normalizeAngle(numState.getLM(), FastMath.PI)) + " " + FastMath.toDegrees(MathUtils.normalizeAngle(kepState.getLM(), FastMath.PI))); break; } } } stream.close(); System.out.println("Results saved as file " + output); File output1 = new File(new File(System.getProperty("user.home")), "elts_pv.dat"); PrintStream stream1 = new PrintStream(output1); stream.println("# date pxn pyn pzn vxn vyn vzn pxk pyk pzk vxk vyk vzk"); for (SpacecraftState numState : numStates) { for (SpacecraftState kepState : kepStates) { if (numState.getDate().compareTo(kepState.getDate()) == 0) { final double pxn = numState.getPVCoordinates().getPosition().getX(); final double pyn = numState.getPVCoordinates().getPosition().getY(); final double pzn = numState.getPVCoordinates().getPosition().getZ(); final double vxn = numState.getPVCoordinates().getVelocity().getX(); final double vyn = numState.getPVCoordinates().getVelocity().getY(); final double vzn = numState.getPVCoordinates().getVelocity().getZ(); final double pxk = kepState.getPVCoordinates().getPosition().getX(); final double pyk = kepState.getPVCoordinates().getPosition().getY(); final double pzk = kepState.getPVCoordinates().getPosition().getZ(); final double vxk = kepState.getPVCoordinates().getVelocity().getX(); final double vyk = kepState.getPVCoordinates().getVelocity().getY(); final double vzk = kepState.getPVCoordinates().getVelocity().getZ(); stream1.println(numState.getDate() + " " + pxn + " " + pyn + " " + pzn + " " + vxn + " " + vyn + " " + vzn + " " + pxk + " " + pyk + " " + pzk + " " + vxk + " " + vyk + " " + vzk); break; } } } stream1.close(); System.out.println("Results saved as file " + output1); } catch (OrekitException oe) { System.err.println(oe.getLocalizedMessage()); System.exit(1); } catch (FileNotFoundException fnfe) { System.err.println(fnfe.getLocalizedMessage()); System.exit(1); } }
From source file:fr.cs.examples.attitude.EarthObservation.java
/** Program entry point. * @param args program arguments (unused here) *///www . j av a 2 s . co m public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); final SortedSet<String> output = new TreeSet<String>(); // Initial state definition : date, orbit final AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC()); final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680); final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231); final Orbit initialOrbit = new KeplerianOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initialDate, Constants.EIGEN5C_EARTH_MU); // Attitudes sequence definition final AttitudeProvider dayObservationLaw = new LofOffset(initialOrbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(20), FastMath.toRadians(40), 0); final AttitudeProvider nightRestingLaw = new LofOffset(initialOrbit.getFrame(), LOFType.VVLH); final PVCoordinatesProvider sun = CelestialBodyFactory.getSun(); final PVCoordinatesProvider earth = CelestialBodyFactory.getEarth(); final EventDetector dayNightEvent = new EclipseDetector(sun, 696000000., earth, Constants.WGS84_EARTH_EQUATORIAL_RADIUS).withHandler(new ContinueOnEvent<EclipseDetector>()); final EventDetector nightDayEvent = new EclipseDetector(sun, 696000000., earth, Constants.WGS84_EARTH_EQUATORIAL_RADIUS).withHandler(new ContinueOnEvent<EclipseDetector>()); final AttitudesSequence attitudesSequence = new AttitudesSequence(); final AttitudesSequence.SwitchHandler switchHandler = new AttitudesSequence.SwitchHandler() { public void switchOccurred(AttitudeProvider preceding, AttitudeProvider following, SpacecraftState s) { if (preceding == dayObservationLaw) { output.add(s.getDate() + ": switching to night law"); } else { output.add(s.getDate() + ": switching to day law"); } } }; attitudesSequence.addSwitchingCondition(dayObservationLaw, nightRestingLaw, dayNightEvent, false, true, 10.0, AngularDerivativesFilter.USE_R, switchHandler); attitudesSequence.addSwitchingCondition(nightRestingLaw, dayObservationLaw, nightDayEvent, true, false, 10.0, AngularDerivativesFilter.USE_R, switchHandler); if (dayNightEvent.g(new SpacecraftState(initialOrbit)) >= 0) { // initial position is in daytime attitudesSequence.resetActiveProvider(dayObservationLaw); } else { // initial position is in nighttime attitudesSequence.resetActiveProvider(nightRestingLaw); } // Propagator : consider the analytical Eckstein-Hechler model final Propagator propagator = new EcksteinHechlerPropagator(initialOrbit, attitudesSequence, 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); // Register the switching events to the propagator attitudesSequence.registerSwitchEvents(propagator); propagator.setMasterMode(180.0, new OrekitFixedStepHandler() { public void init(final SpacecraftState s0, final AbsoluteDate t) { } public void handleStep(SpacecraftState currentState, boolean isLast) throws PropagationException { try { DecimalFormatSymbols angleDegree = new DecimalFormatSymbols(Locale.US); angleDegree.setDecimalSeparator('\u00b0'); DecimalFormat ad = new DecimalFormat(" 00.000;-00.000", angleDegree); // the Earth position in spacecraft frame should be along spacecraft Z axis // during nigthtime and away from it during daytime due to roll and pitch offsets final Vector3D earth = currentState.toTransform().transformPosition(Vector3D.ZERO); final double pointingOffset = Vector3D.angle(earth, Vector3D.PLUS_K); // the g function is the eclipse indicator, its an angle between Sun and Earth limb, // positive when Sun is outside of Earth limb, negative when Sun is hidden by Earth limb final double eclipseAngle = dayNightEvent.g(currentState); output.add(currentState.getDate() + " " + ad.format(FastMath.toDegrees(eclipseAngle)) + " " + ad.format(FastMath.toDegrees(pointingOffset))); } catch (OrekitException oe) { throw new PropagationException(oe); } } }); // Propagate from the initial date for the fixed duration SpacecraftState finalState = propagator.propagate(initialDate.shiftedBy(12600.)); // we print the lines according to lexicographic order, which is chronological order here // to make sure out of orders calls between step handler and event handlers don't mess things up for (final String line : output) { System.out.println(line); } System.out.println("Propagation ended at " + finalState.getDate()); } catch (OrekitException oe) { System.err.println(oe.getMessage()); } }
From source file:edu.mit.fss.examples.ISSFederate.java
/** * The main method. This configures the Orekit data path, creates the * ISS federate objects and launches the associated graphical user * interface./*from w w w . j ava2 s . c o m*/ * * @param args the arguments * @throws RTIexception the RTI exception * @throws URISyntaxException */ public static void main(String[] args) throws RTIexception, URISyntaxException { BasicConfigurator.configure(); boolean headless = false; logger.debug("Setting Orekit data path."); System.setProperty(DataProvidersManager.OREKIT_DATA_PATH, new File(ISSFederate.class.getResource("/orekit-data.zip").toURI()).getAbsolutePath()); logger.trace("Creating federate instance."); final ISSFederate federate = new ISSFederate(); logger.trace("Setting minimum step duration and time step."); long timeStep = 60 * 1000, minimumStepDuration = 100; federate.setMinimumStepDuration(minimumStepDuration); federate.setTimeStep(timeStep); try { logger.debug("Loading TLE data from file."); BufferedReader br = new BufferedReader(new InputStreamReader( federate.getClass().getClassLoader().getResourceAsStream("edu/mit/fss/examples/data.tle"))); final SpaceSystem satellite; final SurfaceSystem station1, station2, station3; while (br.ready()) { if (br.readLine().matches(".*ISS.*")) { logger.debug("Found ISS data."); logger.trace("Adding FSS supplier space system."); satellite = new SpaceSystem("FSS Supplier", new TLE(br.readLine(), br.readLine()), 5123e3); federate.addObject(satellite); logger.trace("Adding Keio ground station."); station1 = new SurfaceSystem("Keio", new GeodeticPoint(FastMath.toRadians(35.551929), FastMath.toRadians(139.647119), 300), satellite.getState().getDate(), 5123e3, 5); federate.addObject(station1); logger.trace("Adding SkolTech ground station."); station2 = new SurfaceSystem("SkolTech", new GeodeticPoint(FastMath.toRadians(55.698679), FastMath.toRadians(37.571994), 200), satellite.getState().getDate(), 5123e3, 5); federate.addObject(station2); logger.trace("Adding MIT ground station."); station3 = new SurfaceSystem("MIT", new GeodeticPoint(FastMath.toRadians(42.360184), FastMath.toRadians(-71.093742), 100), satellite.getState().getDate(), 5123e3, 5); federate.addObject(station3); try { logger.trace("Setting inital time."); federate.setInitialTime( satellite.getInitialState().getDate().toDate(TimeScalesFactory.getUTC()).getTime()); } catch (IllegalArgumentException | OrekitException e) { logger.error(e.getMessage()); e.printStackTrace(); } if (!headless) { logger.debug("Launching the graphical user interface."); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { MemberFrame frame = new MemberFrame(federate, new MultiComponentPanel( Arrays.asList(new SpaceSystemPanel(federate, satellite), new SurfaceSystemPanel(federate, station1), new SurfaceSystemPanel(federate, station2), new SurfaceSystemPanel(federate, station3)))); frame.pack(); frame.setVisible(true); } }); } break; } } br.close(); } catch (InvocationTargetException | InterruptedException | OrekitException | IOException e) { e.printStackTrace(); logger.fatal(e); } logger.trace("Setting federate name, type, and FOM path."); federate.getConnection().setFederateName("ISS"); federate.getConnection().setFederateType("FSS Supplier"); federate.getConnection().setFederationName("FSS"); federate.getConnection().setFomPath( new File(federate.getClass().getClassLoader().getResource("edu/mit/fss/hla/fss.xml").toURI()) .getAbsolutePath()); federate.getConnection().setOfflineMode(false); federate.connect(); if (headless) { federate.setMinimumStepDuration(10); federate.initialize(); federate.run(); } }