List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getNorm
public double getNorm()
From source file:org.orekit.forces.gravity.CunninghamAttractionModelTest.java
@Test public void testIssue97() throws IOException, ParseException, OrekitException { Utils.setDataRoot("regular-data:potential/grgs-format"); GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true)); // pos-vel (from a ZOOM ephemeris reference) final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06, -1.32931592294715829e+04);/*ww w . j ava 2 s . co m*/ final Vector3D vel = new Vector3D(2.14718074509906819e+03, 7.38239351251748485e+03, -1.14097953925384523e+01); final SpacecraftState spacecraftState = new SpacecraftState(new CartesianOrbit(new PVCoordinates(pos, vel), FramesFactory.getGCRF(), new AbsoluteDate(2005, 3, 5, 0, 24, 0.0, TimeScalesFactory.getTAI()), GravityFieldFactory.getUnnormalizedProvider(1, 1).getMu())); AccelerationRetriever accelerationRetriever = new AccelerationRetriever(); for (int i = 2; i <= 69; i++) { // perturbing force (ITRF2008 central body frame) final ForceModel cunModel = new CunninghamAttractionModel( FramesFactory.getITRF(IERSConventions.IERS_2010, true), GravityFieldFactory.getUnnormalizedProvider(i, i)); final ForceModel droModel = new DrozinerAttractionModel( FramesFactory.getITRF(IERSConventions.IERS_2010, true), GravityFieldFactory.getUnnormalizedProvider(i, i)); /** * Compute acceleration */ cunModel.addContribution(spacecraftState, accelerationRetriever); final Vector3D cunGamma = accelerationRetriever.getAcceleration(); droModel.addContribution(spacecraftState, accelerationRetriever); final Vector3D droGamma = accelerationRetriever.getAcceleration(); Assert.assertEquals(0.0, cunGamma.subtract(droGamma).getNorm(), 2.2e-9 * droGamma.getNorm()); } }
From source file:org.orekit.forces.gravity.DrozinerAttractionModelTest.java
@Test public void testTesserealWithHolmesFeaterstoneReference() throws OrekitException, IOException, ParseException { Utils.setDataRoot("regular-data:potential/grgs-format"); GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true)); UnnormalizedSphericalHarmonicsProvider unnormalized = GravityFieldFactory.getUnnormalizedProvider(10, 10); NormalizedSphericalHarmonicsProvider normalized = GravityFieldFactory.getNormalizedProvider(10, 10); // initialization AbsoluteDate date = new AbsoluteDate(new DateComponents(2000, 07, 01), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC()); double i = FastMath.toRadians(98.7); double omega = FastMath.toRadians(93.0); double OMEGA = FastMath.toRadians(15.0 * 22.5); Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, i, omega, OMEGA, 0, PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); propagator = new NumericalPropagator(new ClassicalRungeKuttaIntegrator(100)); propagator.addForceModel(new HolmesFeatherstoneAttractionModel(itrf2008, normalized)); propagator.setInitialState(new SpacecraftState(orbit)); SpacecraftState hfOrb = propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY)); propagator.removeForceModels();// w w w. ja v a2 s.c om propagator.addForceModel(new DrozinerAttractionModel(itrf2008, unnormalized)); propagator.setInitialState(new SpacecraftState(orbit)); SpacecraftState drozOrb = propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY)); Vector3D dif = hfOrb.getPVCoordinates().getPosition().subtract(drozOrb.getPVCoordinates().getPosition()); Assert.assertEquals(0, dif.getNorm(), 3.1e-7); Assert.assertTrue(propagator.getCalls() < 3500); }
From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel.java
/** Compute the value of the gravity field. * @param date current date/*from w w w . ja va2 s. co m*/ * @param position position at which gravity field is desired in body frame * @return value of the gravity field (central and non-central parts summed together) * @exception OrekitException if position cannot be converted to central body frame */ public double value(final AbsoluteDate date, final Vector3D position) throws OrekitException { return mu / position.getNorm() + nonCentralPart(date, position); }
From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModelTest.java
@Test public void testValue() throws OrekitException { int max = 50; NormalizedSphericalHarmonicsProvider provider = new GleasonProvider(max, max); HolmesFeatherstoneAttractionModel model = new HolmesFeatherstoneAttractionModel(itrf, provider); double r = 1.25; for (double lambda = 0; lambda < 2 * FastMath.PI; lambda += 0.5) { for (double theta = 0.05; theta < 3.11; theta += 0.03) { Vector3D position = new Vector3D(r * FastMath.sin(theta) * FastMath.cos(lambda), r * FastMath.sin(theta) * FastMath.sin(lambda), r * FastMath.cos(theta)); double refValue = provider.getMu() / position.getNorm() + model.nonCentralPart(AbsoluteDate.GPS_EPOCH, position); double value = model.value(AbsoluteDate.GPS_EPOCH, position); Assert.assertEquals(refValue, value, 1.0e-15 * FastMath.abs(refValue)); }//from w w w .j av a2 s .c o m } }
From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModelTest.java
@Test public void testZonalWithCunninghamReference() throws OrekitException { // initialization AbsoluteDate date = new AbsoluteDate(new DateComponents(2000, 07, 01), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC()); double i = FastMath.toRadians(98.7); double omega = FastMath.toRadians(93.0); double OMEGA = FastMath.toRadians(15.0 * 22.5); Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, i, omega, OMEGA, 0, PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); propagator = new NumericalPropagator(new ClassicalRungeKuttaIntegrator(1000)); propagator.addForceModel(new HolmesFeatherstoneAttractionModel(itrf, GravityFieldFactory.getNormalizedProvider(ae, mu, TideSystem.UNKNOWN, new double[][] { { 0.0 }, { 0.0 }, { normalizedC20 }, { normalizedC30 }, { normalizedC40 }, { normalizedC50 }, { normalizedC60 }, }, new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, }))); propagator.setInitialState(new SpacecraftState(orbit)); SpacecraftState hfOrb = propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY)); propagator.removeForceModels();//from w ww . j av a 2s . com propagator.addForceModel(new CunninghamAttractionModel(itrf, GravityFieldFactory.getUnnormalizedProvider(ae, mu, TideSystem.UNKNOWN, new double[][] { { 0.0 }, { 0.0 }, { unnormalizedC20 }, { unnormalizedC30 }, { unnormalizedC40 }, { unnormalizedC50 }, { unnormalizedC60 }, }, new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, }))); propagator.setInitialState(new SpacecraftState(orbit)); SpacecraftState cOrb = propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY)); Vector3D dif = hfOrb.getPVCoordinates().getPosition().subtract(cOrb.getPVCoordinates().getPosition()); Assert.assertEquals(0, dif.getNorm(), 2e-9); Assert.assertTrue(propagator.getCalls() < 400); }
From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModelTest.java
@Test public void testCompleteWithCunninghamReference() throws OrekitException { Utils.setDataRoot("regular-data:potential/grgs-format"); GravityFieldFactory.addPotentialCoefficientsReader(new GRGSFormatReader("grim4s4_gr", true)); // initialization AbsoluteDate date = new AbsoluteDate(new DateComponents(2000, 07, 01), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC()); double i = FastMath.toRadians(98.7); double omega = FastMath.toRadians(93.0); double OMEGA = FastMath.toRadians(15.0 * 22.5); Orbit orbit = new KeplerianOrbit(7201009.7124401, 1e-3, i, omega, OMEGA, 0, PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); double[][] tolerances = NumericalPropagator.tolerances(0.01, orbit, OrbitType.CARTESIAN); AbsoluteDate targetDate = date.shiftedBy(3 * Constants.JULIAN_DAY); propagator = new NumericalPropagator( new DormandPrince853Integrator(1.0e-3, 120, tolerances[0], tolerances[1])); propagator.setOrbitType(OrbitType.CARTESIAN); propagator.addForceModel(/*from w ww . java 2s .c om*/ new HolmesFeatherstoneAttractionModel(itrf, GravityFieldFactory.getNormalizedProvider(69, 69))); propagator.setInitialState(new SpacecraftState(orbit)); SpacecraftState hfOrb = propagator.propagate(targetDate); propagator.removeForceModels(); propagator.addForceModel( new CunninghamAttractionModel(itrf, GravityFieldFactory.getUnnormalizedProvider(69, 69))); propagator.setInitialState(new SpacecraftState(orbit)); SpacecraftState cOrb = propagator.propagate(targetDate); Vector3D dif = hfOrb.getPVCoordinates().getPosition().subtract(cOrb.getPVCoordinates().getPosition()); Assert.assertEquals(0, dif.getNorm(), 4e-5); }
From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModelTest.java
private double accelerationRelativeError(ForceModel testModel, ForceModel referenceModel, SpacecraftState state) throws OrekitException { AccelerationRetriever accelerationRetriever = new AccelerationRetriever(); testModel.addContribution(state, accelerationRetriever); final Vector3D testAcceleration = accelerationRetriever.getAcceleration(); referenceModel.addContribution(state, accelerationRetriever); final Vector3D referenceAcceleration = accelerationRetriever.getAcceleration(); return testAcceleration.subtract(referenceAcceleration).getNorm() / referenceAcceleration.getNorm(); }
From source file:org.orekit.forces.maneuvers.SmallManeuverAnalyticalModel.java
/** Build a maneuver defined in user-specified frame. * @param state0 state at maneuver date, <em>before</em> the maneuver * is performed/*from w w w . ja v a2s . c om*/ * @param frame frame in which velocity increment is defined * @param dV velocity increment in specified frame * @param isp engine specific impulse (s) * @exception OrekitException if velocity increment frame cannot be transformed */ public SmallManeuverAnalyticalModel(final SpacecraftState state0, final Frame frame, final Vector3D dV, final double isp) throws OrekitException { this.state0 = state0; this.massRatio = FastMath.exp(-dV.getNorm() / (Constants.G0_STANDARD_GRAVITY * isp)); // use equinoctial orbit type if possible, Keplerian if nearly hyperbolic orbits type = (state0.getE() < 0.9) ? OrbitType.EQUINOCTIAL : OrbitType.KEPLERIAN; // compute initial Jacobian final double[][] fullJacobian = new double[6][6]; j0 = new double[6][3]; final Orbit orbit0 = type.convertType(state0.getOrbit()); orbit0.getJacobianWrtCartesian(PositionAngle.MEAN, fullJacobian); for (int i = 0; i < j0.length; ++i) { System.arraycopy(fullJacobian[i], 3, j0[i], 0, 3); } // use lazy evaluation for j0Dot, as it is used only when Jacobians are evaluated j0Dot = null; // compute maneuver effect on Keplerian (or equinoctial) elements inertialDV = frame.getTransformTo(state0.getFrame(), state0.getDate()).transformVector(dV); // compute mean anomaly change: dM(t1) = dM(t0) + ksi * da * (t1 - t0) final double mu = state0.getMu(); final double a = state0.getA(); ksi = -1.5 * FastMath.sqrt(mu / a) / (a * a); }
From source file:org.orekit.forces.maneuvers.SmallManeuverAnalyticalModelTest.java
private BoundedPropagator getEphemeris(final Orbit orbit, final double mass, final AbsoluteDate t0, final Vector3D dV, final double f, final double isp) throws OrekitException { AttitudeProvider law = new LofOffset(orbit.getFrame(), LOFType.LVLH); final SpacecraftState initialState = new SpacecraftState(orbit, law.getAttitude(orbit, orbit.getDate(), orbit.getFrame()), mass); // set up numerical propagator final double dP = 1.0; double[][] tolerances = NumericalPropagator.tolerances(dP, orbit, orbit.getType()); AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(0.001, 1000, tolerances[0], tolerances[1]);/* w w w .j ava 2 s. c o m*/ integrator.setInitialStepSize(orbit.getKeplerianPeriod() / 100.0); final NumericalPropagator propagator = new NumericalPropagator(integrator); propagator.setOrbitType(orbit.getType()); propagator.setInitialState(initialState); propagator.setAttitudeProvider(law); if (dV.getNorm() > 1.0e-6) { // set up maneuver final double vExhaust = Constants.G0_STANDARD_GRAVITY * isp; final double dt = -(mass * vExhaust / f) * FastMath.expm1(-dV.getNorm() / vExhaust); final ConstantThrustManeuver maneuver = new ConstantThrustManeuver(t0, dt, f, isp, dV.normalize()); propagator.addForceModel(maneuver); } propagator.setEphemerisMode(); propagator.propagate(t0.shiftedBy(5 * orbit.getKeplerianPeriod())); return propagator.getGeneratedEphemeris(); }
From source file:org.orekit.forces.radiation.SolarRadiationPressure.java
/** Get the useful angles for eclipse computation. * @param position the satellite's position in the selected frame. * @param frame in which is defined the position * @param date the date//from w w w . j a v a 2 s . co m * @return the 3 angles {(satCentral, satSun), Central body apparent radius, Sun apparent radius} * @exception OrekitException if the trajectory is inside the Earth */ private double[] getEclipseAngles(final Vector3D position, final Frame frame, final AbsoluteDate date) throws OrekitException { final double[] angle = new double[3]; final Vector3D satSunVector = sun.getPVCoordinates(date, frame).getPosition().subtract(position); // Sat-Sun / Sat-CentralBody angle angle[0] = Vector3D.angle(satSunVector, position.negate()); // Central body apparent radius final double r = position.getNorm(); if (r <= equatorialRadius) { throw new OrekitException(OrekitMessages.TRAJECTORY_INSIDE_BRILLOUIN_SPHERE, r); } angle[1] = FastMath.asin(equatorialRadius / r); // Sun apparent radius angle[2] = FastMath.asin(Constants.SUN_RADIUS / satSunVector.getNorm()); return angle; }