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.frames.LOFType.java
/** Get the transform from an inertial frame defining position-velocity and the local orbital frame. * @param date current date/*from w w w .ja v a 2 s .c om*/ * @param pv position-velocity of the spacecraft in some inertial frame * @return transform from the frame where position-velocity are defined to local orbital frame */ public Transform transformFromInertial(final AbsoluteDate date, final PVCoordinates pv) { // compute the translation part of the transform final Transform translation = new Transform(date, pv.negate()); // compute the rotation part of the transform final Rotation r = rotationFromInertial(pv); final Vector3D p = pv.getPosition(); final Vector3D momentum = pv.getMomentum(); final Transform rotation = new Transform(date, r, new Vector3D(1.0 / p.getNormSq(), r.applyTo(momentum))); return new Transform(date, translation, rotation); }
From source file:org.orekit.frames.TIRFProvider.java
/** Get the transform from CIRF 2000 at specified date. * <p>The update considers the earth rotation from IERS data.</p> * @param date new value of the date//w w w.j av a2 s . co m * @return transform at the specified date * @exception OrekitException if the nutation model data embedded in the * library cannot be read */ public Transform getTransform(final AbsoluteDate date) throws OrekitException { // compute proper rotation final double correctedERA = era.value(date).getValue(); // compute true angular rotation of Earth, in rad/s final double lod = (eopHistory == null) ? 0.0 : eopHistory.getLOD(date); final double omp = AVE * (1 - lod / Constants.JULIAN_DAY); final Vector3D rotationRate = new Vector3D(omp, Vector3D.PLUS_K); // set up the transform from parent CIRF2000 final Rotation rotation = new Rotation(Vector3D.PLUS_K, -correctedERA); return new Transform(date, rotation, rotationRate); }
From source file:org.orekit.frames.TransformTest.java
@Test public void testRotPV() { RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l); // Instant Rotation only for (int i = 0; i < 10; ++i) { // Random instant rotation Rotation instantRot = randomRotation(rnd); Vector3D normAxis = instantRot.getAxis(); double w = FastMath.abs(instantRot.getAngle()) / Constants.JULIAN_DAY; // random rotation Rotation rot = randomRotation(rnd); // so we have a transform Transform tr = new Transform(AbsoluteDate.J2000_EPOCH, rot, new Vector3D(w, normAxis)); // random position, velocity, acceleration Vector3D pos = randomVector(1.0e3, rnd); Vector3D vel = randomVector(1.0, rnd); Vector3D acc = randomVector(1.0e-3, rnd); PVCoordinates pvOne = new PVCoordinates(pos, vel, acc); // we obtain PVCoordinates pvTwo = tr.transformPVCoordinates(pvOne); // test inverse Vector3D resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity(); checkVector(resultvel, vel, 1.0e-15); }//from w ww . j a v a 2 s . com }
From source file:org.orekit.frames.TransformTest.java
@Test public void testTransPV() { RandomGenerator rnd = new Well19937a(0x73d5554d99427af0l); // translation velocity only : for (int i = 0; i < 10; ++i) { // random position, velocity and acceleration Vector3D pos = randomVector(1.0e3, rnd); Vector3D vel = randomVector(1.0, rnd); Vector3D acc = randomVector(1.0e-3, rnd); PVCoordinates pvOne = new PVCoordinates(pos, vel, acc); // random transform Vector3D transPos = randomVector(1.0e3, rnd); Vector3D transVel = randomVector(1.0, rnd); Vector3D transAcc = randomVector(1.0e-3, rnd); Transform tr = new Transform(AbsoluteDate.J2000_EPOCH, transPos, transVel, transAcc); double dt = 1; // we should obtain Vector3D good = tr.transformPosition(pos.add(new Vector3D(dt, vel))).add(new Vector3D(dt, transVel)); // we have PVCoordinates pvTwo = tr.transformPVCoordinates(pvOne); Vector3D result = pvTwo.getPosition().add(new Vector3D(dt, pvTwo.getVelocity())); checkVector(good, result, 1.0e-15); // test inverse Vector3D resultvel = tr.getInverse().transformPVCoordinates(pvTwo).getVelocity(); checkVector(resultvel, vel, 1.0e-15); }//w w w. ja va 2 s. co m }
From source file:org.orekit.frames.TransformTest.java
@Test public void testShift() { // the following transform corresponds to a frame moving along the line x=1 and rotating around its -z axis // the linear motion velocity is (0, +1, 0), the angular rate is PI/2 // at t = -1 the frame origin is at (1, -1, 0), its X axis is equal to Xref and its Y axis is equal to Yref // at t = 0 the frame origin is at (1, 0, 0), its X axis is equal to -Yref and its Y axis is equal to Xref // at t = +1 the frame origin is at (1, +1, 0), its X axis is equal to -Xref and its Y axis is equal to -Yref AbsoluteDate date = AbsoluteDate.GALILEO_EPOCH; double alpha0 = 0.5 * FastMath.PI; double omega = 0.5 * FastMath.PI; Transform t = new Transform(date, new Transform(date, Vector3D.MINUS_I, Vector3D.MINUS_J, Vector3D.ZERO), new Transform(date, new Rotation(Vector3D.PLUS_K, alpha0), new Vector3D(omega, Vector3D.MINUS_K))); for (double dt = -10.0; dt < 10.0; dt += 0.125) { Transform shifted = t.shiftedBy(dt); // the following point should always remain at moving frame origin PVCoordinates expectedFixedPoint = shifted.transformPVCoordinates( new PVCoordinates(new Vector3D(1, dt, 0), Vector3D.PLUS_J, Vector3D.ZERO)); checkVector(expectedFixedPoint.getPosition(), Vector3D.ZERO, 1.0e-14); checkVector(expectedFixedPoint.getVelocity(), Vector3D.ZERO, 1.0e-14); checkVector(expectedFixedPoint.getAcceleration(), Vector3D.ZERO, 1.0e-14); // fixed frame origin apparent motion in moving frame PVCoordinates expectedApparentMotion = shifted.transformPVCoordinates(PVCoordinates.ZERO); double c = FastMath.cos(alpha0 + omega * dt); double s = FastMath.sin(alpha0 + omega * dt); Vector3D referencePosition = new Vector3D(-c + dt * s, -s - dt * c, 0); Vector3D referenceVelocity = new Vector3D((1 + omega) * s + dt * omega * c, -(1 + omega) * c + dt * omega * s, 0); Vector3D referenceAcceleration = new Vector3D(omega * (2 + omega) * c - dt * omega * omega * s, omega * (2 + omega) * s + dt * omega * omega * c, 0); checkVector(expectedApparentMotion.getPosition(), referencePosition, 1.0e-14); checkVector(expectedApparentMotion.getVelocity(), referenceVelocity, 1.0e-14); checkVector(expectedApparentMotion.getAcceleration(), referenceAcceleration, 1.0e-14); }/*from ww w .j a va2 s. co m*/ }
From source file:org.orekit.frames.VEISProvider.java
/** Get the transform from GTOD at specified date. * @param date new value of the date// www . j a v a2s. c om * @return transform at the specified date * @exception OrekitException if data embedded in the library cannot be read */ public Transform getTransform(final AbsoluteDate date) throws OrekitException { // offset from FIFTIES epoch (UT1 scale) final double dtai = date.durationFrom(VST_REFERENCE); final double dutc = TimeScalesFactory.getUTC().offsetFromTAI(date); final double dut1 = 0.0; // fixed at 0 since Veis parent is GTOD frame WITHOUT EOP corrections final double tut1 = dtai + dutc + dut1; final double ttd = tut1 / Constants.JULIAN_DAY; final double rdtt = ttd - (int) ttd; // compute Veis sidereal time, in radians final double vst = (VST0 + VST1 * ttd + MathUtils.TWO_PI * rdtt) % MathUtils.TWO_PI; // compute angular rotation of Earth, in rad/s final Vector3D rotationRate = new Vector3D(-VSTD, Vector3D.PLUS_K); // set up the transform from parent GTOD return new Transform(date, new Rotation(Vector3D.PLUS_K, vst), rotationRate); }
From source file:org.orekit.orbits.KeplerianOrbit.java
/** Constructor from cartesian parameters. * * <p> The acceleration provided in {@code pvCoordinates} is accessible using * {@link #getPVCoordinates()} and {@link #getPVCoordinates(Frame)}. All other methods * use {@code mu} and the position to compute the acceleration, including * {@link #shiftedBy(double)} and {@link #getPVCoordinates(AbsoluteDate, Frame)}. * * @param pvCoordinates the PVCoordinates of the satellite * @param frame the frame in which are defined the {@link PVCoordinates} * (<em>must</em> be a {@link Frame#isPseudoInertial pseudo-inertial frame}) * @param mu central attraction coefficient (m/s) * @exception IllegalArgumentException if frame is not a {@link * Frame#isPseudoInertial pseudo-inertial frame} *//*from www.j ava2 s. c om*/ public KeplerianOrbit(final TimeStampedPVCoordinates pvCoordinates, final Frame frame, final double mu) throws IllegalArgumentException { super(pvCoordinates, frame, mu); // compute inclination final Vector3D momentum = pvCoordinates.getMomentum(); final double m2 = momentum.getNormSq(); i = Vector3D.angle(momentum, Vector3D.PLUS_K); // compute right ascension of ascending node raan = Vector3D.crossProduct(Vector3D.PLUS_K, momentum).getAlpha(); // preliminary computations for parameters depending on orbit shape (elliptic or hyperbolic) final Vector3D pvP = pvCoordinates.getPosition(); final Vector3D pvV = pvCoordinates.getVelocity(); final double r = pvP.getNorm(); final double V2 = pvV.getNormSq(); final double rV2OnMu = r * V2 / mu; // compute semi-major axis (will be negative for hyperbolic orbits) a = r / (2 - rV2OnMu); final double muA = mu * a; // compute true anomaly if (a > 0) { // elliptic or circular orbit final double eSE = Vector3D.dotProduct(pvP, pvV) / FastMath.sqrt(muA); final double eCE = rV2OnMu - 1; e = FastMath.sqrt(eSE * eSE + eCE * eCE); v = ellipticEccentricToTrue(FastMath.atan2(eSE, eCE)); } else { // hyperbolic orbit final double eSH = Vector3D.dotProduct(pvP, pvV) / FastMath.sqrt(-muA); final double eCH = rV2OnMu - 1; e = FastMath.sqrt(1 - m2 / muA); v = hyperbolicEccentricToTrue(FastMath.log((eCH + eSH) / (eCH - eSH)) / 2); } // compute perigee argument final Vector3D node = new Vector3D(raan, 0.0); final double px = Vector3D.dotProduct(pvP, node); final double py = Vector3D.dotProduct(pvP, Vector3D.crossProduct(momentum, node)) / FastMath.sqrt(m2); pa = FastMath.atan2(py, px) - v; }
From source file:org.orekit.orbits.KeplerianOrbit.java
/** Compute the Jacobian of the orbital parameters with respect to the cartesian parameters. * <p>/*from www .j a v a 2s.c o m*/ * Element {@code jacobian[i][j]} is the derivative of parameter i of the orbit with * respect to cartesian coordinate j (x for j=0, y for j=1, z for j=2, xDot for j=3, * yDot for j=4, zDot for j=5). * </p> * @return 6x6 Jacobian matrix */ private double[][] computeJacobianMeanWrtCartesianElliptical() { final double[][] jacobian = new double[6][6]; // compute various intermediate parameters final PVCoordinates pvc = getPVCoordinates(); final Vector3D position = pvc.getPosition(); final Vector3D velocity = pvc.getVelocity(); final Vector3D momentum = pvc.getMomentum(); final double v2 = velocity.getNormSq(); final double r2 = position.getNormSq(); final double r = FastMath.sqrt(r2); final double r3 = r * r2; final double px = position.getX(); final double py = position.getY(); final double pz = position.getZ(); final double vx = velocity.getX(); final double vy = velocity.getY(); final double vz = velocity.getZ(); final double mx = momentum.getX(); final double my = momentum.getY(); final double mz = momentum.getZ(); final double mu = getMu(); final double sqrtMuA = FastMath.sqrt(a * mu); final double sqrtAoMu = FastMath.sqrt(a / mu); final double a2 = a * a; final double twoA = 2 * a; final double rOnA = r / a; final double oMe2 = 1 - e * e; final double epsilon = FastMath.sqrt(oMe2); final double sqrtRec = 1 / epsilon; final double cosI = FastMath.cos(i); final double sinI = FastMath.sin(i); final double cosPA = FastMath.cos(pa); final double sinPA = FastMath.sin(pa); final double pv = Vector3D.dotProduct(position, velocity); final double cosE = (a - r) / (a * e); final double sinE = pv / (e * sqrtMuA); // da final Vector3D vectorAR = new Vector3D(2 * a2 / r3, position); final Vector3D vectorARDot = velocity.scalarMultiply(2 * a2 / mu); fillHalfRow(1, vectorAR, jacobian[0], 0); fillHalfRow(1, vectorARDot, jacobian[0], 3); // de final double factorER3 = pv / twoA; final Vector3D vectorER = new Vector3D(cosE * v2 / (r * mu), position, sinE / sqrtMuA, velocity, -factorER3 * sinE / sqrtMuA, vectorAR); final Vector3D vectorERDot = new Vector3D(sinE / sqrtMuA, position, cosE * 2 * r / mu, velocity, -factorER3 * sinE / sqrtMuA, vectorARDot); fillHalfRow(1, vectorER, jacobian[1], 0); fillHalfRow(1, vectorERDot, jacobian[1], 3); // dE / dr (Eccentric anomaly) final double coefE = cosE / (e * sqrtMuA); final Vector3D vectorEAnR = new Vector3D(-sinE * v2 / (e * r * mu), position, coefE, velocity, -factorER3 * coefE, vectorAR); // dE / drDot final Vector3D vectorEAnRDot = new Vector3D(-sinE * 2 * r / (e * mu), velocity, coefE, position, -factorER3 * coefE, vectorARDot); // precomputing some more factors final double s1 = -sinE * pz / r - cosE * vz * sqrtAoMu; final double s2 = -cosE * pz / r3; final double s3 = -sinE * vz / (2 * sqrtMuA); final double t1 = sqrtRec * (cosE * pz / r - sinE * vz * sqrtAoMu); final double t2 = sqrtRec * (-sinE * pz / r3); final double t3 = sqrtRec * (cosE - e) * vz / (2 * sqrtMuA); final double t4 = sqrtRec * (e * sinI * cosPA * sqrtRec - vz * sqrtAoMu); final Vector3D s = new Vector3D(cosE / r, Vector3D.PLUS_K, s1, vectorEAnR, s2, position, s3, vectorAR); final Vector3D sDot = new Vector3D(-sinE * sqrtAoMu, Vector3D.PLUS_K, s1, vectorEAnRDot, s3, vectorARDot); final Vector3D t = new Vector3D(sqrtRec * sinE / r, Vector3D.PLUS_K) .add(new Vector3D(t1, vectorEAnR, t2, position, t3, vectorAR, t4, vectorER)); final Vector3D tDot = new Vector3D(sqrtRec * (cosE - e) * sqrtAoMu, Vector3D.PLUS_K, t1, vectorEAnRDot, t3, vectorARDot, t4, vectorERDot); // di final double factorI1 = -sinI * sqrtRec / sqrtMuA; final double i1 = factorI1; final double i2 = -factorI1 * mz / twoA; final double i3 = factorI1 * mz * e / oMe2; final double i4 = cosI * sinPA; final double i5 = cosI * cosPA; fillHalfRow(i1, new Vector3D(vy, -vx, 0), i2, vectorAR, i3, vectorER, i4, s, i5, t, jacobian[2], 0); fillHalfRow(i1, new Vector3D(-py, px, 0), i2, vectorARDot, i3, vectorERDot, i4, sDot, i5, tDot, jacobian[2], 3); // dpa fillHalfRow(cosPA / sinI, s, -sinPA / sinI, t, jacobian[3], 0); fillHalfRow(cosPA / sinI, sDot, -sinPA / sinI, tDot, jacobian[3], 3); // dRaan final double factorRaanR = 1 / (mu * a * oMe2 * sinI * sinI); fillHalfRow(-factorRaanR * my, new Vector3D(0, vz, -vy), factorRaanR * mx, new Vector3D(-vz, 0, vx), jacobian[4], 0); fillHalfRow(-factorRaanR * my, new Vector3D(0, -pz, py), factorRaanR * mx, new Vector3D(pz, 0, -px), jacobian[4], 3); // dM fillHalfRow(rOnA, vectorEAnR, -sinE, vectorER, jacobian[5], 0); fillHalfRow(rOnA, vectorEAnRDot, -sinE, vectorERDot, jacobian[5], 3); return jacobian; }
From source file:org.orekit.orbits.KeplerianOrbit.java
/** Compute the Jacobian of the orbital parameters with respect to the cartesian parameters. * <p>//from w ww. j a v a 2 s .c o m * Element {@code jacobian[i][j]} is the derivative of parameter i of the orbit with * respect to cartesian coordinate j (x for j=0, y for j=1, z for j=2, xDot for j=3, * yDot for j=4, zDot for j=5). * </p> * @return 6x6 Jacobian matrix */ private double[][] computeJacobianMeanWrtCartesianHyperbolic() { final double[][] jacobian = new double[6][6]; // compute various intermediate parameters final PVCoordinates pvc = getPVCoordinates(); final Vector3D position = pvc.getPosition(); final Vector3D velocity = pvc.getVelocity(); final Vector3D momentum = pvc.getMomentum(); final double r2 = position.getNormSq(); final double r = FastMath.sqrt(r2); final double r3 = r * r2; final double x = position.getX(); final double y = position.getY(); final double z = position.getZ(); final double vx = velocity.getX(); final double vy = velocity.getY(); final double vz = velocity.getZ(); final double mx = momentum.getX(); final double my = momentum.getY(); final double mz = momentum.getZ(); final double mu = getMu(); final double absA = -a; final double sqrtMuA = FastMath.sqrt(absA * mu); final double a2 = a * a; final double rOa = r / absA; final double cosI = FastMath.cos(i); final double sinI = FastMath.sin(i); final double pv = Vector3D.dotProduct(position, velocity); // da final Vector3D vectorAR = new Vector3D(-2 * a2 / r3, position); final Vector3D vectorARDot = velocity.scalarMultiply(-2 * a2 / mu); fillHalfRow(-1, vectorAR, jacobian[0], 0); fillHalfRow(-1, vectorARDot, jacobian[0], 3); // differentials of the momentum final double m = momentum.getNorm(); final double oOm = 1 / m; final Vector3D dcXP = new Vector3D(0, vz, -vy); final Vector3D dcYP = new Vector3D(-vz, 0, vx); final Vector3D dcZP = new Vector3D(vy, -vx, 0); final Vector3D dcXV = new Vector3D(0, -z, y); final Vector3D dcYV = new Vector3D(z, 0, -x); final Vector3D dcZV = new Vector3D(-y, x, 0); final Vector3D dCP = new Vector3D(mx * oOm, dcXP, my * oOm, dcYP, mz * oOm, dcZP); final Vector3D dCV = new Vector3D(mx * oOm, dcXV, my * oOm, dcYV, mz * oOm, dcZV); // dp final double mOMu = m / mu; final Vector3D dpP = new Vector3D(2 * mOMu, dCP); final Vector3D dpV = new Vector3D(2 * mOMu, dCV); // de final double p = m * mOMu; final double moO2ae = 1 / (2 * absA * e); final double m2OaMu = -p / absA; fillHalfRow(moO2ae, dpP, m2OaMu * moO2ae, vectorAR, jacobian[1], 0); fillHalfRow(moO2ae, dpV, m2OaMu * moO2ae, vectorARDot, jacobian[1], 3); // di final double cI1 = 1 / (m * sinI); final double cI2 = cosI * cI1; fillHalfRow(cI2, dCP, -cI1, dcZP, jacobian[2], 0); fillHalfRow(cI2, dCV, -cI1, dcZV, jacobian[2], 3); // dPA final double cP1 = y * oOm; final double cP2 = -x * oOm; final double cP3 = -(mx * cP1 + my * cP2); final double cP4 = cP3 * oOm; final double cP5 = -1 / (r2 * sinI * sinI); final double cP6 = z * cP5; final double cP7 = cP3 * cP5; final Vector3D dacP = new Vector3D(cP1, dcXP, cP2, dcYP, cP4, dCP, oOm, new Vector3D(-my, mx, 0)); final Vector3D dacV = new Vector3D(cP1, dcXV, cP2, dcYV, cP4, dCV); final Vector3D dpoP = new Vector3D(cP6, dacP, cP7, Vector3D.PLUS_K); final Vector3D dpoV = new Vector3D(cP6, dacV); final double re2 = r2 * e * e; final double recOre2 = (p - r) / re2; final double resOre2 = (pv * mOMu) / re2; final Vector3D dreP = new Vector3D(mOMu, velocity, pv / mu, dCP); final Vector3D dreV = new Vector3D(mOMu, position, pv / mu, dCV); final Vector3D davP = new Vector3D(-resOre2, dpP, recOre2, dreP, resOre2 / r, position); final Vector3D davV = new Vector3D(-resOre2, dpV, recOre2, dreV); fillHalfRow(1, dpoP, -1, davP, jacobian[3], 0); fillHalfRow(1, dpoV, -1, davV, jacobian[3], 3); // dRAAN final double cO0 = cI1 * cI1; final double cO1 = mx * cO0; final double cO2 = -my * cO0; fillHalfRow(cO1, dcYP, cO2, dcXP, jacobian[4], 0); fillHalfRow(cO1, dcYV, cO2, dcXV, jacobian[4], 3); // dM final double s2a = pv / (2 * absA); final double oObux = 1 / FastMath.sqrt(m * m + mu * absA); final double scasbu = pv * oObux; final Vector3D dauP = new Vector3D(1 / sqrtMuA, velocity, -s2a / sqrtMuA, vectorAR); final Vector3D dauV = new Vector3D(1 / sqrtMuA, position, -s2a / sqrtMuA, vectorARDot); final Vector3D dbuP = new Vector3D(oObux * mu / 2, vectorAR, m * oObux, dCP); final Vector3D dbuV = new Vector3D(oObux * mu / 2, vectorARDot, m * oObux, dCV); final Vector3D dcuP = new Vector3D(oObux, velocity, -scasbu * oObux, dbuP); final Vector3D dcuV = new Vector3D(oObux, position, -scasbu * oObux, dbuV); fillHalfRow(1, dauP, -e / (1 + rOa), dcuP, jacobian[5], 0); fillHalfRow(1, dauV, -e / (1 + rOa), dcuV, jacobian[5], 3); return jacobian; }
From source file:org.orekit.orbits.KeplerianParametersTest.java
@Test public void testHyperbola() { KeplerianOrbit orbit = new KeplerianOrbit(-10000000.0, 2.5, 0.3, 0, 0, 0.0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, mu); Vector3D perigeeP = orbit.getPVCoordinates().getPosition(); Vector3D u = perigeeP.normalize(); Vector3D focus1 = Vector3D.ZERO; Vector3D focus2 = new Vector3D(-2 * orbit.getA() * orbit.getE(), u); for (double dt = -5000; dt < 5000; dt += 60) { PVCoordinates pv = orbit.shiftedBy(dt).getPVCoordinates(); double d1 = Vector3D.distance(pv.getPosition(), focus1); double d2 = Vector3D.distance(pv.getPosition(), focus2); Assert.assertEquals(-2 * orbit.getA(), FastMath.abs(d1 - d2), 1.0e-6); KeplerianOrbit rebuilt = new KeplerianOrbit(pv, orbit.getFrame(), orbit.getDate().shiftedBy(dt), mu); Assert.assertEquals(-10000000.0, rebuilt.getA(), 1.0e-6); Assert.assertEquals(2.5, rebuilt.getE(), 1.0e-13); }// w w w.j av a 2s . c o m }