List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D crossProduct
public static Vector3D crossProduct(final Vector3D v1, final Vector3D v2)
From source file:org.orekit.bodies.OneAxisEllipsoid.java
/** {@inheritDoc} */ public TimeStampedPVCoordinates projectToGround(final TimeStampedPVCoordinates pv, final Frame frame) throws OrekitException { // transform point to body frame final Transform toBody = frame.getTransformTo(bodyFrame, pv.getDate()); final TimeStampedPVCoordinates pvInBodyFrame = toBody.transformPVCoordinates(pv); final Vector3D p = pvInBodyFrame.getPosition(); final double r = FastMath.hypot(p.getX(), p.getY()); // set up the 2D ellipse corresponding to first principal curvature along meridian final Vector3D meridian = new Vector3D(p.getX() / r, p.getY() / r, 0); final Ellipse firstPrincipalCurvature = new Ellipse(Vector3D.ZERO, meridian, Vector3D.PLUS_K, getA(), getC(), bodyFrame);/*w w w .ja va2 s . c om*/ // project coordinates in the meridian plane final TimeStampedPVCoordinates gpFirst = firstPrincipalCurvature.projectToEllipse(pvInBodyFrame); final Vector3D gpP = gpFirst.getPosition(); final double gr = MathArrays.linearCombination(gpP.getX(), meridian.getX(), gpP.getY(), meridian.getY()); final double gz = gpP.getZ(); // topocentric frame final Vector3D east = new Vector3D(-meridian.getY(), meridian.getX(), 0); final Vector3D zenith = new Vector3D(gr * getC() / getA(), meridian, gz * getA() / getC(), Vector3D.PLUS_K) .normalize(); final Vector3D north = Vector3D.crossProduct(zenith, east); // set up the ellipse corresponding to second principal curvature in the zenith/east plane final Ellipse secondPrincipalCurvature = getPlaneSection(gpP, north); final TimeStampedPVCoordinates gpSecond = secondPrincipalCurvature.projectToEllipse(pvInBodyFrame); final Vector3D gpV = gpFirst.getVelocity().add(gpSecond.getVelocity()); final Vector3D gpA = gpFirst.getAcceleration().add(gpSecond.getAcceleration()); // moving projected point final TimeStampedPVCoordinates groundPV = new TimeStampedPVCoordinates(pv.getDate(), gpP, gpV, gpA); // transform moving projected point back to initial frame return toBody.getInverse().transformPVCoordinates(groundPV); }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
@Test public void testGroundProjectionTaylor() throws OrekitException { Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); Frame eme2000 = FramesFactory.getEME2000(); OneAxisEllipsoid model = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf); TimeStampedPVCoordinates initPV = new TimeStampedPVCoordinates(AbsoluteDate.J2000_EPOCH.shiftedBy(584.), new Vector3D(3220103., 69623., 6449822.), new Vector3D(6414.7, -2006., -3180.), Vector3D.ZERO); Orbit orbit = new EquinoctialOrbit(initPV, eme2000, Constants.EIGEN5C_EARTH_MU); TimeStampedPVCoordinates pv0 = orbit.getPVCoordinates(orbit.getDate(), model.getBodyFrame()); PVCoordinatesProvider groundTaylor = model.projectToGround(pv0, model.getBodyFrame()) .toTaylorProvider(model.getBodyFrame()); TimeStampedPVCoordinates g0 = groundTaylor.getPVCoordinates(orbit.getDate(), model.getBodyFrame()); Vector3D zenith = pv0.getPosition().subtract(g0.getPosition()).normalize(); Vector3D acrossTrack = Vector3D.crossProduct(zenith, g0.getVelocity()).normalize(); Vector3D alongTrack = Vector3D.crossProduct(acrossTrack, zenith).normalize(); for (double dt = -1; dt < 1; dt += 0.01) { AbsoluteDate date = orbit.getDate().shiftedBy(dt); Vector3D taylorP = groundTaylor.getPVCoordinates(date, model.getBodyFrame()).getPosition(); Vector3D refP = model.projectToGround(orbit.getPVCoordinates(date, model.getBodyFrame()).getPosition(), date, model.getBodyFrame()); Vector3D delta = taylorP.subtract(refP); Assert.assertEquals(0.0, Vector3D.dotProduct(delta, alongTrack), 0.0015); Assert.assertEquals(0.0, Vector3D.dotProduct(delta, acrossTrack), 0.0007); Assert.assertEquals(0.0, Vector3D.dotProduct(delta, zenith), 0.00002); }//from w ww.j a v a2s . c o m }
From source file:org.orekit.bodies.OneAxisEllipsoidTest.java
private void checkCartesianToEllipsoidic(double ae, double f, double x, double y, double z, double longitude, double latitude, double altitude) throws OrekitException { AbsoluteDate date = AbsoluteDate.J2000_EPOCH; Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true); OneAxisEllipsoid model = new OneAxisEllipsoid(ae, f, frame); GeodeticPoint gp = model.transform(new Vector3D(x, y, z), frame, date); Assert.assertEquals(longitude, MathUtils.normalizeAngle(gp.getLongitude(), longitude), 1.0e-10); Assert.assertEquals(latitude, gp.getLatitude(), 1.0e-10); Assert.assertEquals(altitude, gp.getAltitude(), 1.0e-10 * FastMath.abs(ae)); Vector3D rebuiltNadir = Vector3D.crossProduct(gp.getSouth(), gp.getWest()); Assert.assertEquals(0, rebuiltNadir.subtract(gp.getNadir()).getNorm(), 1.0e-15); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraft.java
/** Build a spacecraft model with linear rotation of solar array. * <p>/*from www . j a va 2 s . c om*/ * The spacecraft body is described by an array of surface vectors. Each facet of * the body is describe by a vector normal to the facet (pointing outward of the spacecraft) * and whose norm is the surface area in m. * </p> * <p> * Solar arrays orientation will be a regular rotation from the * reference orientation at reference date and using a constant * rotation rate. * </p> * @param facets body facets (only the facets with strictly positive area will be stored) * @param sun sun model * @param solarArrayArea area of the solar array (m) * @param solarArrayAxis solar array rotation axis in satellite frame * @param referenceDate reference date for the solar array rotation * @param referenceNormal direction of the solar array normal at reference date * in spacecraft frame * @param rotationRate rotation rate of the solar array, may be 0 (rad/s) * @param dragCoeff drag coefficient (used only for drag) * @param absorptionCoeff absorption coefficient between 0.0 an 1.0 * (used only for radiation pressure) * @param reflectionCoeff specular reflection coefficient between 0.0 an 1.0 * (used only for radiation pressure) */ public BoxAndSolarArraySpacecraft(final Facet[] facets, final PVCoordinatesProvider sun, final double solarArrayArea, final Vector3D solarArrayAxis, final AbsoluteDate referenceDate, final Vector3D referenceNormal, final double rotationRate, final double dragCoeff, final double absorptionCoeff, final double reflectionCoeff) { this.facets = filter(facets.clone()); this.sun = sun; this.solarArrayArea = solarArrayArea; this.referenceDate = referenceDate; this.rotationRate = rotationRate; this.saZ = solarArrayAxis.normalize(); this.saY = Vector3D.crossProduct(saZ, referenceNormal).normalize(); this.saX = Vector3D.crossProduct(saY, saZ); this.dragCoeff = dragCoeff; this.absorptionCoeff = absorptionCoeff; this.specularReflectionCoeff = reflectionCoeff; this.diffuseReflectionCoeff = 1 - (absorptionCoeff + reflectionCoeff); }
From source file:org.orekit.forces.BoxAndSolarArraySpacecraftTest.java
@Test public void testWithoutReflection() throws OrekitException { AbsoluteDate initialDate = propagator.getInitialState().getDate(); CelestialBody sun = CelestialBodyFactory.getSun(); BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(1.5, 3.5, 2.5, sun, 20.0, Vector3D.PLUS_J, 1.0, 1.0, 0.0);/*from w w w . ja v a2 s . c o m*/ Vector3D earthRot = new Vector3D(0.0, 0.0, 7.292115e-4); for (double dt = 0; dt < 4000; dt += 60) { AbsoluteDate date = initialDate.shiftedBy(dt); SpacecraftState state = propagator.propagate(date); // simple Earth fixed atmosphere Vector3D p = state.getPVCoordinates().getPosition(); Vector3D v = state.getPVCoordinates().getVelocity(); Vector3D vAtm = Vector3D.crossProduct(earthRot, p); Vector3D relativeVelocity = vAtm.subtract(v); Vector3D drag = s.dragAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), 0.001, relativeVelocity); Assert.assertEquals(0.0, Vector3D.angle(relativeVelocity, drag), 1.0e-10); Vector3D sunDirection = sun.getPVCoordinates(date, state.getFrame()).getPosition().normalize(); Vector3D flux = new Vector3D(-4.56e-6, sunDirection); Vector3D radiation = s.radiationPressureAcceleration(state.getDate(), state.getFrame(), state.getPVCoordinates().getPosition(), state.getAttitude().getRotation(), state.getMass(), flux); Assert.assertEquals(0.0, Vector3D.angle(flux, radiation), 1.0e-9); } }
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 ava 2s . co m Assert.assertEquals(0, test.getNorm(), 2.9e-5); }
From source file:org.orekit.forces.gravity.CunninghamAttractionModelTest.java
@Test public void testTimeDependentField() throws IOException, ParseException, OrekitException { Utils.setDataRoot("regular-data:potential/icgem-format"); GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("eigen-6s-truncated", true)); final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06, -1.32931592294715829e+04);//from w ww. j a v a 2s . c o 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())); double dP = 0.1; double duration = 3 * Constants.JULIAN_DAY; BoundedPropagator fixedFieldEphemeris = createEphemeris(dP, spacecraftState, duration, GravityFieldFactory.getConstantUnnormalizedProvider(8, 8)); BoundedPropagator varyingFieldEphemeris = createEphemeris(dP, spacecraftState, duration, GravityFieldFactory.getUnnormalizedProvider(8, 8)); double step = 60.0; double maxDeltaT = 0; double maxDeltaN = 0; double maxDeltaW = 0; for (AbsoluteDate date = fixedFieldEphemeris.getMinDate(); date .compareTo(fixedFieldEphemeris.getMaxDate()) < 0; date = date.shiftedBy(step)) { PVCoordinates pvFixedField = fixedFieldEphemeris.getPVCoordinates(date, FramesFactory.getGCRF()); PVCoordinates pvVaryingField = varyingFieldEphemeris.getPVCoordinates(date, FramesFactory.getGCRF()); Vector3D t = pvFixedField.getVelocity().normalize(); Vector3D w = pvFixedField.getMomentum().normalize(); Vector3D n = Vector3D.crossProduct(w, t); Vector3D delta = pvVaryingField.getPosition().subtract(pvFixedField.getPosition()); maxDeltaT = FastMath.max(maxDeltaT, FastMath.abs(Vector3D.dotProduct(delta, t))); maxDeltaN = FastMath.max(maxDeltaN, FastMath.abs(Vector3D.dotProduct(delta, n))); maxDeltaW = FastMath.max(maxDeltaW, FastMath.abs(Vector3D.dotProduct(delta, w))); } Assert.assertTrue(maxDeltaT > 0.15); Assert.assertTrue(maxDeltaT < 0.25); Assert.assertTrue(maxDeltaN > 0.01); Assert.assertTrue(maxDeltaN < 0.02); Assert.assertTrue(maxDeltaW > 0.05); Assert.assertTrue(maxDeltaW < 0.10); }
From source file:org.orekit.forces.gravity.HolmesFeatherstoneAttractionModelTest.java
@Test public void testTimeDependentField() throws OrekitException { Utils.setDataRoot("regular-data:potential/icgem-format"); GravityFieldFactory.addPotentialCoefficientsReader(new ICGEMFormatReader("eigen-6s-truncated", true)); final Vector3D pos = new Vector3D(6.46885878304673824e+06, -1.88050918456274318e+06, -1.32931592294715829e+04);/* w ww .ja v a2 s . c o 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())); double dP = 0.1; double duration = 3 * Constants.JULIAN_DAY; BoundedPropagator fixedFieldEphemeris = createEphemeris(dP, spacecraftState, duration, GravityFieldFactory.getConstantNormalizedProvider(8, 8)); BoundedPropagator varyingFieldEphemeris = createEphemeris(dP, spacecraftState, duration, GravityFieldFactory.getNormalizedProvider(8, 8)); double step = 60.0; double maxDeltaT = 0; double maxDeltaN = 0; double maxDeltaW = 0; for (AbsoluteDate date = fixedFieldEphemeris.getMinDate(); date .compareTo(fixedFieldEphemeris.getMaxDate()) < 0; date = date.shiftedBy(step)) { PVCoordinates pvFixedField = fixedFieldEphemeris.getPVCoordinates(date, FramesFactory.getGCRF()); PVCoordinates pvVaryingField = varyingFieldEphemeris.getPVCoordinates(date, FramesFactory.getGCRF()); Vector3D t = pvFixedField.getVelocity().normalize(); Vector3D w = pvFixedField.getMomentum().normalize(); Vector3D n = Vector3D.crossProduct(w, t); Vector3D delta = pvVaryingField.getPosition().subtract(pvFixedField.getPosition()); maxDeltaT = FastMath.max(maxDeltaT, FastMath.abs(Vector3D.dotProduct(delta, t))); maxDeltaN = FastMath.max(maxDeltaN, FastMath.abs(Vector3D.dotProduct(delta, n))); maxDeltaW = FastMath.max(maxDeltaW, FastMath.abs(Vector3D.dotProduct(delta, w))); } Assert.assertTrue(maxDeltaT > 0.15); Assert.assertTrue(maxDeltaT < 0.25); Assert.assertTrue(maxDeltaN > 0.01); Assert.assertTrue(maxDeltaN < 0.02); Assert.assertTrue(maxDeltaW > 0.05); Assert.assertTrue(maxDeltaW < 0.10); }
From source file:org.orekit.frames.LocalOrbitalFrameTest.java
@Test public void testTNW() throws OrekitException { AbsoluteDate date = initDate.shiftedBy(400); PVCoordinates pv = provider.getPVCoordinates(date, inertialFrame); checkFrame(LOFType.TNW, date, pv.getVelocity(), Vector3D.crossProduct(pv.getMomentum(), pv.getVelocity()), pv.getMomentum(), pv.getMomentum().negate()); }
From source file:org.orekit.frames.LocalOrbitalFrameTest.java
@Test public void testQSW() throws OrekitException { AbsoluteDate date = initDate.shiftedBy(400); PVCoordinates pv = provider.getPVCoordinates(date, inertialFrame); checkFrame(LOFType.QSW, date, pv.getPosition(), Vector3D.crossProduct(pv.getMomentum(), pv.getPosition()), pv.getMomentum(), pv.getMomentum().negate()); }