List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D Vector3D
public Vector3D(double a, Vector3D u)
From source file:org.orekit.attitudes.SpinStabilized.java
/** Creates a new instance. * @param nonRotatingLaw underlying non-rotating attitude provider * @param start start date of the rotation * @param axis rotation axis in satellite frame * @param rate spin rate in radians per seconds *//*from w ww .j av a 2s .c o m*/ public SpinStabilized(final AttitudeProvider nonRotatingLaw, final AbsoluteDate start, final Vector3D axis, final double rate) { this.nonRotatingLaw = nonRotatingLaw; this.start = start; this.axis = axis; this.rate = rate; this.spin = new Vector3D(rate / axis.getNorm(), axis); }
From source file:org.orekit.bodies.IAUPoleFactory.java
/** Get an IAU pole. * @param body body for which the pole is requested * @return IAU pole for the body, or dummy GCRF aligned pole * for barycenters//from www . j av a2 s . com */ public static IAUPole getIAUPole(final JPLEphemeridesLoader.EphemerisType body) { switch (body) { case SUN: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = 5715331729495237139L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { return new Vector3D(FastMath.toRadians(286.13), FastMath.toRadians(63.87)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { return FastMath.toRadians(84.176 + 14.1844000 * d(date)); } }; case MERCURY: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = -5769710119654037007L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { final double t = t(date); return new Vector3D(FastMath.toRadians(281.0097 - 0.0328 * t), FastMath.toRadians(61.4143 - 0.0049 * t)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { final double[] m = computeMi(date); return FastMath.toRadians(329.5469 + 6.1385025 * d(date) + 0.00993822 * FastMath.sin(m[0]) - 0.00104581 * FastMath.sin(m[1]) - 0.00010280 * FastMath.sin(m[2]) - 0.00002364 * FastMath.sin(m[3]) - 0.00000532 * FastMath.sin(m[4])); } /** Compute the Mercury angles M<sub>i</sub>. * @param date date * @return array of Mercury angles, with M<sub>i</sub> stored at index i-1 */ private double[] computeMi(final AbsoluteDate date) { final double d = d(date); return new double[] { FastMath.toRadians(174.791096 + 4.092335 * d), // M1 FastMath.toRadians(349.582171 + 8.184670 * d), // M2 FastMath.toRadians(164.373257 + 12.277005 * d), // M3 FastMath.toRadians(339.164343 + 16.369340 * d), // M4 FastMath.toRadians(153.955429 + 20.461675 * d), // M5 }; } }; case VENUS: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = 7030506277976648896L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { return new Vector3D(FastMath.toRadians(272.76), FastMath.toRadians(67.16)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { return FastMath.toRadians(160.20 - 1.4813688 * d(date)); } }; case EARTH: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = 6912325697192667056L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { final double t = t(date); return new Vector3D(FastMath.toRadians(0.00 - 0.641 * t), FastMath.toRadians(90.00 - 0.557 * t)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { return FastMath.toRadians(190.147 + 360.9856235 * d(date)); } }; case MOON: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = -1310155975084976571L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { final double[] e = computeEi(date); final double t = t(date); return new Vector3D( FastMath.toRadians(269.9949 + 0.0031 * t - 3.8787 * FastMath.sin(e[0]) - 0.1204 * FastMath.sin(e[1]) + 0.0700 * FastMath.sin(e[2]) - 0.0172 * FastMath.sin(e[3]) + 0.0072 * FastMath.sin(e[5]) - 0.0052 * FastMath.sin(e[9]) + 0.0043 * FastMath.sin(e[12])), FastMath.toRadians( 66.5392 + 0.0130 * t + 1.5419 * FastMath.cos(e[0]) + 0.0239 * FastMath.cos(e[1]) - 0.0278 * FastMath.cos(e[2]) + 0.0068 * FastMath.cos(e[3]) - 0.0029 * FastMath.cos(e[5]) + 0.0009 * FastMath.cos(e[6]) + 0.0008 * FastMath.cos(e[9]) - 0.0009 * FastMath.cos(e[12]))); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { final double[] e = computeEi(date); final double d = d(date); return FastMath .toRadians(38.3213 + (13.17635815 - 1.4e-12 * d) * d + 3.5610 * FastMath.sin(e[0]) + 0.1208 * FastMath.sin(e[1]) - 0.0642 * FastMath.sin(e[2]) + 0.0158 * FastMath.sin(e[3]) + 0.0252 * FastMath.sin(e[4]) - 0.0066 * FastMath.sin(e[5]) - 0.0047 * FastMath.sin(e[6]) - 0.0046 * FastMath.sin(e[7]) + 0.0028 * FastMath.sin(e[8]) + 0.0052 * FastMath.sin(e[9]) + 0.0040 * FastMath.sin(e[10]) + 0.0019 * FastMath.sin(e[11]) - 0.0044 * FastMath.sin(e[12])); } /** Compute the Moon angles E<sub>i</sub>. * @param date date * @return array of Moon angles, with E<sub>i</sub> stored at index i-1 */ private double[] computeEi(final AbsoluteDate date) { final double d = d(date); return new double[] { FastMath.toRadians(125.045 - 0.0529921 * d), // E1 FastMath.toRadians(250.089 - 0.1059842 * d), // E2 FastMath.toRadians(260.008 + 13.0120009 * d), // E3 FastMath.toRadians(176.625 + 13.3407154 * d), // E4 FastMath.toRadians(357.529 + 0.9856003 * d), // E5 FastMath.toRadians(311.589 + 26.4057084 * d), // E6 FastMath.toRadians(134.963 + 13.0649930 * d), // E7 FastMath.toRadians(276.617 + 0.3287146 * d), // E8 FastMath.toRadians(34.226 + 1.7484877 * d), // E9 FastMath.toRadians(15.134 - 0.1589763 * d), // E10 FastMath.toRadians(119.743 + 0.0036096 * d), // E11 FastMath.toRadians(239.961 + 0.1643573 * d), // E12 FastMath.toRadians(25.053 + 12.9590088 * d) // E13 }; } }; case MARS: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = 1471983418540015411L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { final double t = t(date); return new Vector3D(FastMath.toRadians(317.68143 - 0.1061 * t), FastMath.toRadians(52.88650 - 0.0609 * t)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { return FastMath.toRadians(176.630 + 350.89198226 * d(date)); } }; case JUPITER: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = 6959753758673537524L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { final double t = t(date); final double ja = FastMath.toRadians(99.360714 + 4850.4046 * t); final double jb = FastMath.toRadians(175.895369 + 1191.9605 * t); final double jc = FastMath.toRadians(300.323162 + 262.5475 * t); final double jd = FastMath.toRadians(114.012305 + 6070.2476 * t); final double je = FastMath.toRadians(49.511251 + 64.3000 * t); return new Vector3D( FastMath.toRadians(268.056595 - 0.006499 * t + 0.000117 * FastMath.sin(ja) + 0.000938 * FastMath.sin(jb) + 0.001432 * FastMath.sin(jc) + 0.000030 * FastMath.sin(jd) + 0.002150 * FastMath.sin(je)), FastMath.toRadians(64.495303 + 0.002413 * t) + 0.000050 * FastMath.cos(ja) + 0.000404 * FastMath.cos(jb) + 0.000617 * FastMath.cos(jc) - 0.000013 * FastMath.cos(jd) + 0.000926 * FastMath.cos(je)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { return FastMath.toRadians(284.95 + 870.5360000 * d(date)); } }; case SATURN: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = -1082211873912149774L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { final double t = t(date); return new Vector3D(FastMath.toRadians(40.589 - 0.036 * t), FastMath.toRadians(83.537 - 0.004 * t)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { return FastMath.toRadians(38.90 + 810.7939024 * d(date)); } }; case URANUS: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = 362792230470085154L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { return new Vector3D(FastMath.toRadians(257.311), FastMath.toRadians(-15.175)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { return FastMath.toRadians(203.81 - 501.1600928 * d(date)); } }; case NEPTUNE: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = 560614555734665287L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { final double n = FastMath.toRadians(357.85 + 52.316 * t(date)); return new Vector3D(FastMath.toRadians(299.36 + 0.70 * FastMath.sin(n)), FastMath.toRadians(43.46 - 0.51 * FastMath.cos(n))); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { final double n = FastMath.toRadians(357.85 + 52.316 * t(date)); return FastMath.toRadians(253.18 + 536.3128492 * d(date) - 0.48 * FastMath.sin(n)); } }; case PLUTO: return new IAUPole() { /** Serializable UID. */ private static final long serialVersionUID = -1277113129327018062L; /** {@inheritDoc }*/ public Vector3D getPole(final AbsoluteDate date) { return new Vector3D(FastMath.toRadians(132.993), FastMath.toRadians(-6.163)); } /** {@inheritDoc }*/ public double getPrimeMeridianAngle(final AbsoluteDate date) { return FastMath.toRadians(302.695 + 56.3625225 * d(date)); } }; default: return new GCRFAligned(); } }
From source file:org.orekit.bodies.SolarBodyTest.java
private void checkPV(PVCoordinatesProvider body, AbsoluteDate date, Frame frame, Vector3D position, Vector3D velocity) throws OrekitException { PVCoordinates pv = body.getPVCoordinates(date, frame); final double posScale = 149597870691.0; final double velScale = posScale / Constants.JULIAN_DAY; PVCoordinates reference = new PVCoordinates(new Vector3D(posScale, position), new Vector3D(velScale, velocity)); PVCoordinates error = new PVCoordinates(reference, pv); Assert.assertEquals(0, error.getPosition().getNorm(), 2.0e-3); Assert.assertEquals(0, error.getVelocity().getNorm(), 5.0e-10); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** {@inheritDoc} */ public Vector3D dragAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation, final double mass, final double density, final Vector3D relativeVelocity) throws OrekitException { // relative velocity in spacecraft frame final Vector3D v = rotation.applyTo(relativeVelocity); // solar array contribution final Vector3D solarArrayFacet = new Vector3D(solarArrayArea, getNormal(date, frame, position, rotation)); double sv = FastMath.abs(Vector3D.dotProduct(solarArrayFacet, v)); // body facets contribution for (final Facet facet : facets) { final double dot = Vector3D.dotProduct(facet.getNormal(), v); if (dot < 0) { // the facet intercepts the incoming flux sv -= facet.getArea() * dot; }/*from ww w . ja va 2 s . com*/ } return new Vector3D(sv * density * dragCoeff / (2.0 * mass), relativeVelocity); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** {@inheritDoc} */ public FieldVector3D<DerivativeStructure> dragAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation, final double mass, final double density, final Vector3D relativeVelocity, final String paramName) throws OrekitException { if (!DRAG_COEFFICIENT.equals(paramName)) { throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, DRAG_COEFFICIENT); }//from ww w .ja va 2 s .co m final DerivativeStructure dragCoeffDS = new DerivativeStructure(1, 1, 0, dragCoeff); // relative velocity in spacecraft frame final Vector3D v = rotation.applyTo(relativeVelocity); // solar array contribution final Vector3D solarArrayFacet = new Vector3D(solarArrayArea, getNormal(date, frame, position, rotation)); double sv = FastMath.abs(Vector3D.dotProduct(solarArrayFacet, v)); // body facets contribution for (final Facet facet : facets) { final double dot = Vector3D.dotProduct(facet.getNormal(), v); if (dot < 0) { // the facet intercepts the incoming flux sv -= facet.getArea() * dot; } } return new FieldVector3D<DerivativeStructure>(dragCoeffDS.multiply(sv * density / (2.0 * mass)), relativeVelocity); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** {@inheritDoc} */ public Vector3D radiationPressureAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation, final double mass, final Vector3D flux) throws OrekitException { if (flux.getNormSq() < Precision.SAFE_MIN) { // null illumination (we are probably in umbra) return Vector3D.ZERO; }//from ww w .j a v a 2 s. co m // radiation flux in spacecraft frame final Vector3D fluxSat = rotation.applyTo(flux); // solar array contribution Vector3D normal = getNormal(date, frame, position, rotation); double dot = Vector3D.dotProduct(normal, fluxSat); if (dot > 0) { // the solar array is illuminated backward, // fix signs to compute contribution correctly dot = -dot; normal = normal.negate(); } Vector3D force = facetRadiationAcceleration(normal, solarArrayArea, fluxSat, dot); // body facets contribution for (final Facet bodyFacet : facets) { normal = bodyFacet.getNormal(); dot = Vector3D.dotProduct(normal, fluxSat); if (dot < 0) { // the facet intercepts the incoming flux force = force.add(facetRadiationAcceleration(normal, bodyFacet.getArea(), fluxSat, dot)); } } // convert to inertial frame return rotation.applyInverseTo(new Vector3D(1.0 / mass, force)); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraftTest.java
@Test public void testPlaneSpecularReflection() throws OrekitException { AbsoluteDate initialDate = propagator.getInitialState().getDate(); CelestialBody sun = CelestialBodyFactory.getSun(); BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, 0.0, 0.0, 1.0);/*ww w . j ava 2s. co m*/ for (double dt = 0; dt < 4000; dt += 60) { AbsoluteDate date = initialDate.shiftedBy(dt); SpacecraftState state = propagator.propagate(date); Vector3D sunDirection = sun.getPVCoordinates(date, state.getFrame()).getPosition().normalize(); Vector3D flux = new Vector3D(-4.56e-6, sunDirection); Vector3D acceleration = s.radiationPressureAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), flux); Vector3D normal = state.getAttitude().getRotation().applyInverseTo(s.getNormal(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation())); // solar array normal is slightly misaligned with Sun direction due to Sun being out of orbital plane Assert.assertEquals(15.1, FastMath.toDegrees(Vector3D.angle(sunDirection, normal)), 0.11); // radiation pressure is exactly opposed to solar array normal as there is only specular reflection Assert.assertEquals(180.0, FastMath.toDegrees(Vector3D.angle(acceleration, normal)), 1.0e-3); } }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraftTest.java
@Test public void testPlaneAbsorption() throws OrekitException { AbsoluteDate initialDate = propagator.getInitialState().getDate(); CelestialBody sun = CelestialBodyFactory.getSun(); BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, sun, 20.0, Vector3D.PLUS_J, 0.0, 1.0, 0.0);/* w ww.jav a 2 s . c om*/ for (double dt = 0; dt < 4000; dt += 60) { AbsoluteDate date = initialDate.shiftedBy(dt); SpacecraftState state = propagator.propagate(date); Vector3D sunDirection = sun.getPVCoordinates(date, state.getFrame()).getPosition().normalize(); Vector3D flux = new Vector3D(-4.56e-6, sunDirection); Vector3D acceleration = s.radiationPressureAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), flux); Vector3D normal = state.getAttitude().getRotation().applyInverseTo(s.getNormal(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation())); // solar array normal is slightly misaligned with Sun direction due to Sun being out of orbital plane Assert.assertEquals(15.1, FastMath.toDegrees(Vector3D.angle(sunDirection, normal)), 0.11); // radiation pressure is exactly opposed to Sun direction as there is only absorption Assert.assertEquals(180.0, FastMath.toDegrees(Vector3D.angle(acceleration, sunDirection)), 1.0e-3); } }
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 av a 2 s .com Assert.assertEquals(0, test.getNorm(), 2.9e-5); }
From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModelTest.java
private double[] gradient(final HolmesFeatherstoneAttractionModel model, final AbsoluteDate date, final Vector3D position, final double h) throws OrekitException { return new double[] { differential8(model.nonCentralPart(date, position.add(new Vector3D(-4 * h, Vector3D.PLUS_I))), model.nonCentralPart(date, position.add(new Vector3D(-3 * h, Vector3D.PLUS_I))), model.nonCentralPart(date, position.add(new Vector3D(-2 * h, Vector3D.PLUS_I))), model.nonCentralPart(date, position.add(new Vector3D(-1 * h, Vector3D.PLUS_I))), model.nonCentralPart(date, position.add(new Vector3D(+1 * h, Vector3D.PLUS_I))), model.nonCentralPart(date, position.add(new Vector3D(+2 * h, Vector3D.PLUS_I))), model.nonCentralPart(date, position.add(new Vector3D(+3 * h, Vector3D.PLUS_I))), model.nonCentralPart(date, position.add(new Vector3D(+4 * h, Vector3D.PLUS_I))), h), differential8(model.nonCentralPart(date, position.add(new Vector3D(-4 * h, Vector3D.PLUS_J))), model.nonCentralPart(date, position.add(new Vector3D(-3 * h, Vector3D.PLUS_J))), model.nonCentralPart(date, position.add(new Vector3D(-2 * h, Vector3D.PLUS_J))), model.nonCentralPart(date, position.add(new Vector3D(-1 * h, Vector3D.PLUS_J))), model.nonCentralPart(date, position.add(new Vector3D(+1 * h, Vector3D.PLUS_J))), model.nonCentralPart(date, position.add(new Vector3D(+2 * h, Vector3D.PLUS_J))), model.nonCentralPart(date, position.add(new Vector3D(+3 * h, Vector3D.PLUS_J))), model.nonCentralPart(date, position.add(new Vector3D(+4 * h, Vector3D.PLUS_J))), h), differential8(model.nonCentralPart(date, position.add(new Vector3D(-4 * h, Vector3D.PLUS_K))), model.nonCentralPart(date, position.add(new Vector3D(-3 * h, Vector3D.PLUS_K))), model.nonCentralPart(date, position.add(new Vector3D(-2 * h, Vector3D.PLUS_K))), model.nonCentralPart(date, position.add(new Vector3D(-1 * h, Vector3D.PLUS_K))), model.nonCentralPart(date, position.add(new Vector3D(+1 * h, Vector3D.PLUS_K))), model.nonCentralPart(date, position.add(new Vector3D(+2 * h, Vector3D.PLUS_K))), model.nonCentralPart(date, position.add(new Vector3D(+3 * h, Vector3D.PLUS_K))), model.nonCentralPart(date, position.add(new Vector3D(+4 * h, Vector3D.PLUS_K))), h) }; }