List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getNorm
public double getNorm()
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
private double[] derivativesErrors(PVCoordinatesProvider provider, AbsoluteDate date, Frame frame, OneAxisEllipsoid model) throws OrekitException { List<TimeStampedPVCoordinates> pvList = new ArrayList<TimeStampedPVCoordinates>(); List<TimeStampedPVCoordinates> groundPVList = new ArrayList<TimeStampedPVCoordinates>(); for (double dt = -0.25; dt <= 0.25; dt += 0.125) { TimeStampedPVCoordinates shiftedPV = provider.getPVCoordinates(date.shiftedBy(dt), frame); Vector3D p = model.projectToGround(shiftedPV.getPosition(), shiftedPV.getDate(), frame); pvList.add(shiftedPV);// ww w. java 2 s .co m groundPVList.add(new TimeStampedPVCoordinates(shiftedPV.getDate(), p, Vector3D.ZERO, Vector3D.ZERO)); } TimeStampedPVCoordinates computed = model.projectToGround( TimeStampedPVCoordinates.interpolate(date, CartesianDerivativesFilter.USE_P, pvList), frame); TimeStampedPVCoordinates reference = TimeStampedPVCoordinates.interpolate(date, CartesianDerivativesFilter.USE_P, groundPVList); TimeStampedPVCoordinates pv0 = provider.getPVCoordinates(date, frame); Vector3D p0 = pv0.getPosition(); Vector3D v0 = pv0.getVelocity(); Vector3D a0 = pv0.getAcceleration(); return new double[] { Vector3D.distance(computed.getPosition(), reference.getPosition()) / p0.getNorm(), Vector3D.distance(computed.getVelocity(), reference.getVelocity()) / v0.getNorm(), Vector3D.distance(computed.getAcceleration(), reference.getAcceleration()) / a0.getNorm(), }; }
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.SolarBodyTest.java
private void checkKepler(final PVCoordinatesProvider orbiting, final CelestialBody central, final AbsoluteDate start, final double a, final double epsilon) throws OrekitException { // set up Keplerian orbit of orbiting body around central body Orbit orbit = new KeplerianOrbit(orbiting.getPVCoordinates(start, central.getInertiallyOrientedFrame()), central.getInertiallyOrientedFrame(), start, central.getGM()); KeplerianPropagator propagator = new KeplerianPropagator(orbit); Assert.assertEquals(a, orbit.getA(), 0.02 * a); double duration = FastMath.min(50 * Constants.JULIAN_DAY, 0.01 * orbit.getKeplerianPeriod()); double max = 0; for (AbsoluteDate date = start; date.durationFrom(start) < duration; date = date .shiftedBy(duration / 100)) { PVCoordinates ephemPV = orbiting.getPVCoordinates(date, central.getInertiallyOrientedFrame()); PVCoordinates keplerPV = propagator.propagate(date).getPVCoordinates(); Vector3D error = keplerPV.getPosition().subtract(ephemPV.getPosition()); max = FastMath.max(max, error.getNorm()); }//from w w w .ja v a2 s. co m Assert.assertTrue(max < epsilon * a); }
From source file:org.orekit.forces.AbstractForceModelTest.java
protected void checkParameterDerivative(SpacecraftState state, ForceModel forceModel, String name, double hFactor, double tol) throws OrekitException { try {//from w ww . j a va 2 s . c o m forceModel.accelerationDerivatives(state, "not a parameter"); Assert.fail("an exception should have been thrown"); } catch (UnknownParameterException upe) { // expected } catch (OrekitException oe) { // expected Assert.assertEquals(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, oe.getSpecifier()); } FieldVector3D<DerivativeStructure> accDer = forceModel.accelerationDerivatives(state, name); Vector3D derivative = new Vector3D(accDer.getX().getPartialDerivative(1), accDer.getY().getPartialDerivative(1), accDer.getZ().getPartialDerivative(1)); AccelerationRetriever accelerationRetriever = new AccelerationRetriever(); double p0 = forceModel.getParameter(name); double hParam = hFactor * forceModel.getParameter(name); forceModel.setParameter(name, p0 - 1 * hParam); Assert.assertEquals(p0 - 1 * hParam, forceModel.getParameter(name), 1.0e-10); forceModel.addContribution(state, accelerationRetriever); final Vector3D gammaM1h = accelerationRetriever.getAcceleration(); forceModel.setParameter(name, p0 + 1 * hParam); Assert.assertEquals(p0 + 1 * hParam, forceModel.getParameter(name), 1.0e-10); forceModel.addContribution(state, accelerationRetriever); final Vector3D gammaP1h = accelerationRetriever.getAcceleration(); final Vector3D reference = new Vector3D(1 / (2 * hParam), gammaP1h.subtract(gammaM1h)); final Vector3D delta = derivative.subtract(reference); Assert.assertEquals(0, delta.getNorm(), tol * reference.getNorm()); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** Compute contribution of one facet to force. * <p>This method implements equation 8-44 from David A. Vallado's * Fundamentals of Astrodynamics and Applications, third edition, * 2007, Microcosm Press.</p>/*from w w w .j a va 2s. com*/ * @param normal facet normal * @param area facet area * @param fluxSat radiation pressure flux in spacecraft frame * @param dot dot product of facet and fluxSat (must be negative) * @return contribution of the facet to force in spacecraft frame */ private Vector3D facetRadiationAcceleration(final Vector3D normal, final double area, final Vector3D fluxSat, final double dot) { final double psr = fluxSat.getNorm(); // Vallado's equation 8-44 uses different parameters which are related to our parameters as: // cos (phi) = -dot / (psr * area) // n = facet / area // s = -fluxSat / psr final double cN = 2 * area * dot * (diffuseReflectionCoeff / 3 - specularReflectionCoeff * dot / psr); final double cS = (area * dot / psr) * (specularReflectionCoeff - 1); return new Vector3D(cN, normal, cS, fluxSat); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** Compute contribution of one facet to force. * <p>This method implements equation 8-44 from David A. Vallado's * Fundamentals of Astrodynamics and Applications, third edition, * 2007, Microcosm Press.</p>/* w w w.j av a 2 s. co m*/ * @param normal facet normal * @param area facet area * @param fluxSat radiation pressure flux in spacecraft frame * @param dot dot product of facet and fluxSat (must be negative) * @param specularReflectionCoeffDS specular reflection coefficient * @param diffuseReflectionCoeffDS diffuse reflection coefficient * @return contribution of the facet to force in spacecraft frame */ private FieldVector3D<DerivativeStructure> facetRadiationAcceleration(final Vector3D normal, final double area, final Vector3D fluxSat, final double dot, final DerivativeStructure specularReflectionCoeffDS, final DerivativeStructure diffuseReflectionCoeffDS) { final double psr = fluxSat.getNorm(); // Vallado's equation 8-44 uses different parameters which are related to our parameters as: // cos (phi) = -dot / (psr * area) // n = facet / area // s = -fluxSat / psr final DerivativeStructure cN = diffuseReflectionCoeffDS.divide(3) .subtract(specularReflectionCoeffDS.multiply(dot / psr)).multiply(2 * area * dot); final DerivativeStructure cS = specularReflectionCoeffDS.subtract(1).multiply(area * dot / psr); return new FieldVector3D<DerivativeStructure>(cN, normal, cS, fluxSat); }
From source file:org.orekit.forces.drag.HarrisPriester.java
/** Get the height above the Earth for the given position. * <p>// w ww . j av a2 s.c o m * The height computation is an approximation valid for the considered atmosphere. * </p> * @param position current position in Earth frame * @return height (m) */ private double getHeight(final Vector3D position) { final double a = earth.getEquatorialRadius(); final double f = earth.getFlattening(); final double e2 = f * (2. - f); final double r = position.getNorm(); final double sl = position.getZ() / r; final double cl2 = 1. - sl * sl; final double coef = FastMath.sqrt((1. - e2) / (1. - e2 * cl2)); return r - a * coef; }
From source file:org.orekit.forces.drag.SimpleExponentialAtmosphereTest.java
@Test public void testExpAtmosphere() throws OrekitException { Vector3D posInEME2000 = new Vector3D(10000, Vector3D.PLUS_I); AbsoluteDate date = AbsoluteDate.J2000_EPOCH; Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); SimpleExponentialAtmosphere atm = new SimpleExponentialAtmosphere( new OneAxisEllipsoid(Utils.ae, 1.0 / 298.257222101, itrf), 0.0004, 42000.0, 7500.0); Vector3D vel = atm.getVelocity(date, posInEME2000, FramesFactory.getEME2000()); Transform toBody = FramesFactory.getEME2000().getTransformTo(itrf, date); Vector3D test = Vector3D.crossProduct(toBody.getRotationRate(), posInEME2000); test = test.subtract(vel);//from w w w . j ava2 s .co m Assert.assertEquals(0, test.getNorm(), 2.9e-5); }
From source file:org.orekit.forces.gravity.CunninghamAttractionModelTest.java
@Test public void testZonalWithDrozinerReference() throws OrekitException, ParseException { // 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 CunninghamAttractionModel(itrf2008, GravityFieldFactory.getUnnormalizedProvider(ae, mu, TideSystem.UNKNOWN, new double[][] { { 0.0 }, { 0.0 }, { c20 }, { c30 }, { c40 }, { c50 }, { c60 }, }, new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, }))); propagator.setInitialState(new SpacecraftState(orbit)); SpacecraftState cunnOrb = propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY)); propagator.removeForceModels();//w ww.j a va2 s . c o m propagator.addForceModel(new DrozinerAttractionModel(itrf2008, GravityFieldFactory.getUnnormalizedProvider(ae, mu, TideSystem.UNKNOWN, new double[][] { { 0.0 }, { 0.0 }, { c20 }, { c30 }, { c40 }, { c50 }, { c60 }, }, new double[][] { { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, { 0.0 }, }))); propagator.setInitialState(new SpacecraftState(orbit)); SpacecraftState drozOrb = propagator.propagate(date.shiftedBy(Constants.JULIAN_DAY)); Vector3D dif = cunnOrb.getPVCoordinates().getPosition().subtract(drozOrb.getPVCoordinates().getPosition()); Assert.assertEquals(0, dif.getNorm(), 3.1e-7); Assert.assertTrue(propagator.getCalls() < 400); }