List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getY
public double getY()
From source file:org.orekit.OrekitMatchers.java
/** * Matches a {@link Vector3D} to another one. * * @param vector the reference vector/*w ww. j ava2s . c om*/ * @param absTol the absolute tolerance of comparison, in each dimension. * @param ulps the relative tolerance of comparison in each dimension, in * units in last place. * @return a matcher that matches if either the absolute or relative * comparison matches in each dimension. */ public static Matcher<Vector3D> vectorCloseTo(Vector3D vector, double absTol, int ulps) { return vector(numberCloseTo(vector.getX(), absTol, ulps), numberCloseTo(vector.getY(), absTol, ulps), numberCloseTo(vector.getZ(), absTol, ulps)); }
From source file:org.orekit.propagation.numerical.NumericalPropagatorTest.java
@Test public void testNoExtrapolation() throws OrekitException { // Propagate of the initial at the initial date final SpacecraftState finalState = propagator.propagate(initDate); // Initial orbit definition final Vector3D initialPosition = initialState.getPVCoordinates().getPosition(); final Vector3D initialVelocity = initialState.getPVCoordinates().getVelocity(); // Final orbit definition final Vector3D finalPosition = finalState.getPVCoordinates().getPosition(); final Vector3D finalVelocity = finalState.getPVCoordinates().getVelocity(); // Check results Assert.assertEquals(initialPosition.getX(), finalPosition.getX(), 1.0e-10); Assert.assertEquals(initialPosition.getY(), finalPosition.getY(), 1.0e-10); Assert.assertEquals(initialPosition.getZ(), finalPosition.getZ(), 1.0e-10); Assert.assertEquals(initialVelocity.getX(), finalVelocity.getX(), 1.0e-10); Assert.assertEquals(initialVelocity.getY(), finalVelocity.getY(), 1.0e-10); Assert.assertEquals(initialVelocity.getZ(), finalVelocity.getZ(), 1.0e-10); }
From source file:org.orekit.propagation.numerical.PartialDerivativesEquations.java
/** {@inheritDoc} */ public double[] computeDerivatives(final SpacecraftState s, final double[] pDot) throws OrekitException { final int dim = 3; // Lazy initialization if (dirty) {/*from www .j a v a 2s . c o m*/ // if step has not been set by user, set a default value if (Double.isNaN(hPos)) { hPos = FastMath.sqrt(Precision.EPSILON) * s.getPVCoordinates().getPosition().getNorm(); } // set up derivatives providers derivativesProviders.clear(); derivativesProviders.addAll(propagator.getForceModels()); derivativesProviders.add(propagator.getNewtonianAttractionForceModel()); // check all parameters are handled by at least one Jacobian provider for (final ParameterConfiguration param : selectedParameters) { final String parameterName = param.getParameterName(); boolean found = false; for (final ForceModel provider : derivativesProviders) { if (provider.isSupported(parameterName)) { param.setProvider(provider); found = true; } } if (!found) { // build the list of supported parameters, avoiding duplication final SortedSet<String> set = new TreeSet<String>(); for (final ForceModel provider : derivativesProviders) { for (final String forceModelParameter : provider.getParametersNames()) { set.add(forceModelParameter); } } final StringBuilder builder = new StringBuilder(); for (final String forceModelParameter : set) { if (builder.length() > 0) { builder.append(", "); } builder.append(forceModelParameter); } throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, parameterName, builder.toString()); } } // check the numbers of parameters and matrix size agree if (selectedParameters.size() != paramDim) { throw new OrekitException(OrekitMessages.INITIAL_MATRIX_AND_PARAMETERS_NUMBER_MISMATCH, paramDim, selectedParameters.size()); } dAccdParam = new double[dim]; dAccdPos = new double[dim][dim]; dAccdVel = new double[dim][dim]; dAccdM = (stateDim > 6) ? new double[dim] : null; dirty = false; } // initialize acceleration Jacobians to zero for (final double[] row : dAccdPos) { Arrays.fill(row, 0.0); } for (final double[] row : dAccdVel) { Arrays.fill(row, 0.0); } if (dAccdM != null) { Arrays.fill(dAccdM, 0.0); } // prepare derivation variables, 3 for position, 3 for velocity and optionally 1 for mass final int nbVars = (dAccdM == null) ? 6 : 7; // position corresponds three free parameters final Vector3D position = s.getPVCoordinates().getPosition(); final FieldVector3D<DerivativeStructure> dsP = new FieldVector3D<DerivativeStructure>( new DerivativeStructure(nbVars, 1, 0, position.getX()), new DerivativeStructure(nbVars, 1, 1, position.getY()), new DerivativeStructure(nbVars, 1, 2, position.getZ())); // velocity corresponds three free parameters final Vector3D velocity = s.getPVCoordinates().getVelocity(); final FieldVector3D<DerivativeStructure> dsV = new FieldVector3D<DerivativeStructure>( new DerivativeStructure(nbVars, 1, 3, velocity.getX()), new DerivativeStructure(nbVars, 1, 4, velocity.getY()), new DerivativeStructure(nbVars, 1, 5, velocity.getZ())); // mass corresponds either to a constant or to one free parameter final DerivativeStructure dsM = (dAccdM == null) ? new DerivativeStructure(nbVars, 1, s.getMass()) : new DerivativeStructure(nbVars, 1, 6, s.getMass()); // we should compute attitude partial derivatives with respect to position/velocity // see issue #200 final Rotation rotation = s.getAttitude().getRotation(); final FieldRotation<DerivativeStructure> dsR = new FieldRotation<DerivativeStructure>( new DerivativeStructure(nbVars, 1, rotation.getQ0()), new DerivativeStructure(nbVars, 1, rotation.getQ1()), new DerivativeStructure(nbVars, 1, rotation.getQ2()), new DerivativeStructure(nbVars, 1, rotation.getQ3()), false); // compute acceleration Jacobians for (final ForceModel derivativesProvider : derivativesProviders) { final FieldVector3D<DerivativeStructure> acceleration = derivativesProvider .accelerationDerivatives(s.getDate(), s.getFrame(), dsP, dsV, dsR, dsM); addToRow(acceleration.getX(), 0); addToRow(acceleration.getY(), 1); addToRow(acceleration.getZ(), 2); } // the variational equations of the complete state Jacobian matrix have the // following form for 7x7, i.e. when mass partial derivatives are also considered // (when mass is not considered, only the A, B, D and E matrices are used along // with their derivatives): // [ | | ] [ | | ] [ | | ] // [ Adot | Bdot | Cdot ] [ dVel/dPos = 0 | dVel/dVel = Id | dVel/dm = 0 ] [ A | B | C ] // [ | | ] [ | | ] [ | | ] // --------+--------+--- ---- ------------------+------------------+---------------- -----+-----+----- // [ | | ] [ | | ] [ | | ] // [ Ddot | Edot | Fdot ] = [ dAcc/dPos | dAcc/dVel | dAcc/dm ] * [ D | E | F ] // [ | | ] [ | | ] [ | | ] // --------+--------+--- ---- ------------------+------------------+---------------- -----+-----+----- // [ Gdot | Hdot | Idot ] [ dmDot/dPos = 0 | dmDot/dVel = 0 | dmDot/dm = 0 ] [ G | H | I ] // The A, B, D and E sub-matrices and their derivatives (Adot ...) are 3x3 matrices, // the C and F sub-matrices and their derivatives (Cdot ...) are 3x1 matrices, // the G and H sub-matrices and their derivatives (Gdot ...) are 1x3 matrices, // the I sub-matrix and its derivative (Idot) is a 1x1 matrix. // The expanded multiplication above can be rewritten to take into account // the fixed values found in the sub-matrices in the left factor. This leads to: // [ Adot ] = [ D ] // [ Bdot ] = [ E ] // [ Cdot ] = [ F ] // [ Ddot ] = [ dAcc/dPos ] * [ A ] + [ dAcc/dVel ] * [ D ] + [ dAcc/dm ] * [ G ] // [ Edot ] = [ dAcc/dPos ] * [ B ] + [ dAcc/dVel ] * [ E ] + [ dAcc/dm ] * [ H ] // [ Fdot ] = [ dAcc/dPos ] * [ C ] + [ dAcc/dVel ] * [ F ] + [ dAcc/dm ] * [ I ] // [ Gdot ] = [ 0 ] // [ Hdot ] = [ 0 ] // [ Idot ] = [ 0 ] // The following loops compute these expressions taking care of the mapping of the // (A, B, ... I) matrices into the single dimension array p and of the mapping of the // (Adot, Bdot, ... Idot) matrices into the single dimension array pDot. // copy D, E and F into Adot, Bdot and Cdot final double[] p = s.getAdditionalState(getName()); System.arraycopy(p, dim * stateDim, pDot, 0, dim * stateDim); // compute Ddot, Edot and Fdot for (int i = 0; i < dim; ++i) { final double[] dAdPi = dAccdPos[i]; final double[] dAdVi = dAccdVel[i]; for (int j = 0; j < stateDim; ++j) { pDot[(dim + i) * stateDim + j] = dAdPi[0] * p[j] + dAdPi[1] * p[j + stateDim] + dAdPi[2] * p[j + 2 * stateDim] + dAdVi[0] * p[j + 3 * stateDim] + dAdVi[1] * p[j + 4 * stateDim] + dAdVi[2] * p[j + 5 * stateDim] + ((dAccdM == null) ? 0.0 : dAccdM[i] * p[j + 6 * stateDim]); } } if (dAccdM != null) { // set Gdot, Hdot and Idot to 0 Arrays.fill(pDot, 6 * stateDim, 7 * stateDim, 0.0); } for (int k = 0; k < paramDim; ++k) { // compute the acceleration gradient with respect to current parameter final ParameterConfiguration param = selectedParameters.get(k); final ForceModel provider = param.getProvider(); final FieldVector3D<DerivativeStructure> accDer = provider.accelerationDerivatives(s, param.getParameterName()); dAccdParam[0] = accDer.getX().getPartialDerivative(1); dAccdParam[1] = accDer.getY().getPartialDerivative(1); dAccdParam[2] = accDer.getZ().getPartialDerivative(1); // the variational equations of the parameters Jacobian matrix are computed // one column at a time, they have the following form: // [ ] [ | | ] [ ] [ ] // [ Jdot ] [ dVel/dPos = 0 | dVel/dVel = Id | dVel/dm = 0 ] [ J ] [ dVel/dParam = 0 ] // [ ] [ | | ] [ ] [ ] // -------- ------------------+------------------+---------------- ----- -------------------- // [ ] [ | | ] [ ] [ ] // [ Kdot ] = [ dAcc/dPos | dAcc/dVel | dAcc/dm ] * [ K ] + [ dAcc/dParam ] // [ ] [ | | ] [ ] [ ] // -------- ------------------+------------------+---------------- ----- -------------------- // [ Ldot ] [ dmDot/dPos = 0 | dmDot/dVel = 0 | dmDot/dm = 0 ] [ L ] [ dmDot/dParam = 0 ] // The J and K sub-columns and their derivatives (Jdot ...) are 3 elements columns, // the L sub-colums and its derivative (Ldot) are 1 elements columns. // The expanded multiplication and addition above can be rewritten to take into // account the fixed values found in the sub-matrices in the left factor. This leads to: // [ Jdot ] = [ K ] // [ Kdot ] = [ dAcc/dPos ] * [ J ] + [ dAcc/dVel ] * [ K ] + [ dAcc/dm ] * [ L ] + [ dAcc/dParam ] // [ Ldot ] = [ 0 ] // The following loops compute these expressions taking care of the mapping of the // (J, K, L) columns into the single dimension array p and of the mapping of the // (Jdot, Kdot, Ldot) columns into the single dimension array pDot. // copy K into Jdot final int columnTop = stateDim * stateDim + k; pDot[columnTop] = p[columnTop + 3 * paramDim]; pDot[columnTop + paramDim] = p[columnTop + 4 * paramDim]; pDot[columnTop + 2 * paramDim] = p[columnTop + 5 * paramDim]; // compute Kdot for (int i = 0; i < dim; ++i) { final double[] dAdPi = dAccdPos[i]; final double[] dAdVi = dAccdVel[i]; pDot[columnTop + (dim + i) * paramDim] = dAccdParam[i] + dAdPi[0] * p[columnTop] + dAdPi[1] * p[columnTop + paramDim] + dAdPi[2] * p[columnTop + 2 * paramDim] + dAdVi[0] * p[columnTop + 3 * paramDim] + dAdVi[1] * p[columnTop + 4 * paramDim] + dAdVi[2] * p[columnTop + 5 * paramDim] + ((dAccdM == null) ? 0.0 : dAccdM[i] * p[columnTop + 6 * paramDim]); } if (dAccdM != null) { // set Ldot to 0 pDot[columnTop + 6 * paramDim] = 0; } } // these equations have no effect of the main state itself return null; }
From source file:org.orekit.propagation.semianalytical.dsst.DSSTPropagatorTest.java
@Test public void testNoExtrapolation() throws OrekitException { SpacecraftState state = getLEOrbit(); setDSSTProp(state);/* w ww .j av a 2 s. c o m*/ // Propagation of the initial state at the initial date final SpacecraftState finalState = dsstProp.propagate(state.getDate()); // Initial orbit definition final Vector3D initialPosition = state.getPVCoordinates().getPosition(); final Vector3D initialVelocity = state.getPVCoordinates().getVelocity(); // Final orbit definition final Vector3D finalPosition = finalState.getPVCoordinates().getPosition(); final Vector3D finalVelocity = finalState.getPVCoordinates().getVelocity(); // Check results Assert.assertEquals(initialPosition.getX(), finalPosition.getX(), 0.0); Assert.assertEquals(initialPosition.getY(), finalPosition.getY(), 0.0); Assert.assertEquals(initialPosition.getZ(), finalPosition.getZ(), 0.0); Assert.assertEquals(initialVelocity.getX(), finalVelocity.getX(), 0.0); Assert.assertEquals(initialVelocity.getY(), finalVelocity.getY(), 0.0); Assert.assertEquals(initialVelocity.getZ(), finalVelocity.getZ(), 0.0); }
From source file:org.orekit.utils.AngularCoordinates.java
/** Find a vector from two known cross products. * <p>/*www . j ava 2 s.c o m*/ * We want to find such that: v? = c? and v = c * </p> * <p> * The first equation ( v? = c?) will always be fulfilled exactly, * and the second one will be fulfilled if possible. * </p> * @param v1 vector forming the first known cross product * @param c1 know vector for cross product v? * @param v2 vector forming the second known cross product * @param c2 know vector for cross product v * @param tolerance relative tolerance factor used to check singularities * @return vector such that: v? = c? and v = c * @exception MathIllegalArgumentException if vectors are inconsistent and * no solution can be found */ private static Vector3D inverseCrossProducts(final Vector3D v1, final Vector3D c1, final Vector3D v2, final Vector3D c2, final double tolerance) throws MathIllegalArgumentException { final double v12 = v1.getNormSq(); final double v1n = FastMath.sqrt(v12); final double v22 = v2.getNormSq(); final double v2n = FastMath.sqrt(v22); final double threshold = tolerance * FastMath.max(v1n, v2n); Vector3D omega; try { // create the over-determined linear system representing the two cross products final RealMatrix m = MatrixUtils.createRealMatrix(6, 3); m.setEntry(0, 1, v1.getZ()); m.setEntry(0, 2, -v1.getY()); m.setEntry(1, 0, -v1.getZ()); m.setEntry(1, 2, v1.getX()); m.setEntry(2, 0, v1.getY()); m.setEntry(2, 1, -v1.getX()); m.setEntry(3, 1, v2.getZ()); m.setEntry(3, 2, -v2.getY()); m.setEntry(4, 0, -v2.getZ()); m.setEntry(4, 2, v2.getX()); m.setEntry(5, 0, v2.getY()); m.setEntry(5, 1, -v2.getX()); final RealVector rhs = MatrixUtils.createRealVector( new double[] { c1.getX(), c1.getY(), c1.getZ(), c2.getX(), c2.getY(), c2.getZ() }); // find the best solution we can final DecompositionSolver solver = new QRDecomposition(m, threshold).getSolver(); final RealVector v = solver.solve(rhs); omega = new Vector3D(v.getEntry(0), v.getEntry(1), v.getEntry(2)); } catch (SingularMatrixException sme) { // handle some special cases for which we can compute a solution final double c12 = c1.getNormSq(); final double c1n = FastMath.sqrt(c12); final double c22 = c2.getNormSq(); final double c2n = FastMath.sqrt(c22); if (c1n <= threshold && c2n <= threshold) { // simple special case, velocities are cancelled return Vector3D.ZERO; } else if (v1n <= threshold && c1n >= threshold) { // this is inconsistent, if v? is zero, c? must be 0 too throw new NumberIsTooLargeException(c1n, 0, true); } else if (v2n <= threshold && c2n >= threshold) { // this is inconsistent, if v is zero, c must be 0 too throw new NumberIsTooLargeException(c2n, 0, true); } else if (Vector3D.crossProduct(v1, v2).getNorm() <= threshold && v12 > threshold) { // simple special case, v is redundant with v?, we just ignore it // use the simplest : orthogonal to both v? and c? omega = new Vector3D(1.0 / v12, Vector3D.crossProduct(v1, c1)); } else { throw sme; } } // check results final double d1 = Vector3D.distance(Vector3D.crossProduct(omega, v1), c1); if (d1 > threshold) { throw new NumberIsTooLargeException(d1, 0, true); } final double d2 = Vector3D.distance(Vector3D.crossProduct(omega, v2), c2); if (d2 > threshold) { throw new NumberIsTooLargeException(d2, 0, true); } return omega; }
From source file:org.orekit.utils.PVCoordinatesTest.java
@Test public void testToDerivativeStructureVector2() throws OrekitException { FieldVector3D<DerivativeStructure> fv = new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)).toDerivativeStructureVector(2); Assert.assertEquals(1, fv.getX().getFreeParameters()); Assert.assertEquals(2, fv.getX().getOrder()); Assert.assertEquals(1.0, fv.getX().getReal(), 1.0e-10); Assert.assertEquals(0.1, fv.getY().getReal(), 1.0e-10); Assert.assertEquals(10.0, fv.getZ().getReal(), 1.0e-10); Assert.assertEquals(-1.0, fv.getX().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(-0.1, fv.getY().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(-10.0, fv.getZ().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(10.0, fv.getX().getPartialDerivative(2), 1.0e-15); Assert.assertEquals(-1.0, fv.getY().getPartialDerivative(2), 1.0e-15); Assert.assertEquals(-100.0, fv.getZ().getPartialDerivative(2), 1.0e-15); checkPV(new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)), new PVCoordinates(fv), 1.0e-15); for (double dt = 0; dt < 10; dt += 0.125) { Vector3D p = new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)).shiftedBy(dt).getPosition(); Assert.assertEquals(p.getX(), fv.getX().taylor(dt), 1.0e-14); Assert.assertEquals(p.getY(), fv.getY().taylor(dt), 1.0e-14); Assert.assertEquals(p.getZ(), fv.getZ().taylor(dt), 1.0e-14); }/* www .j av a 2 s .c om*/ }
From source file:org.orekit.utils.PVCoordinatesTest.java
@Test @Deprecated // to be removed when PVCoordinates.interpolate is removed public void testInterpolatePolynomialPV() { Random random = new Random(0xae7771c9933407bdl); AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH; for (int i = 0; i < 20; ++i) { PolynomialFunction px = randomPolynomial(5, random); PolynomialFunction py = randomPolynomial(5, random); PolynomialFunction pz = randomPolynomial(5, random); PolynomialFunction pxDot = px.polynomialDerivative(); PolynomialFunction pyDot = py.polynomialDerivative(); PolynomialFunction pzDot = pz.polynomialDerivative(); PolynomialFunction pxDotDot = pxDot.polynomialDerivative(); PolynomialFunction pyDotDot = pyDot.polynomialDerivative(); PolynomialFunction pzDotDot = pzDot.polynomialDerivative(); List<Pair<AbsoluteDate, PVCoordinates>> sample = new ArrayList<Pair<AbsoluteDate, PVCoordinates>>(); for (double dt : new double[] { 0.0, 0.5, 1.0 }) { Vector3D position = new Vector3D(px.value(dt), py.value(dt), pz.value(dt)); Vector3D velocity = new Vector3D(pxDot.value(dt), pyDot.value(dt), pzDot.value(dt)); sample.add(new Pair<AbsoluteDate, PVCoordinates>(t0.shiftedBy(dt), new PVCoordinates(position, velocity, Vector3D.ZERO))); }//w w w . j a v a 2 s. co m for (double dt = 0; dt < 1.0; dt += 0.01) { PVCoordinates interpolated = PVCoordinates.interpolate(t0.shiftedBy(dt), true, sample); Vector3D p = interpolated.getPosition(); Vector3D v = interpolated.getVelocity(); Vector3D a = interpolated.getAcceleration(); Assert.assertEquals(px.value(dt), p.getX(), 1.0e-15 * p.getNorm()); Assert.assertEquals(py.value(dt), p.getY(), 1.0e-15 * p.getNorm()); Assert.assertEquals(pz.value(dt), p.getZ(), 1.0e-15 * p.getNorm()); Assert.assertEquals(pxDot.value(dt), v.getX(), 1.0e-15 * v.getNorm()); Assert.assertEquals(pyDot.value(dt), v.getY(), 1.0e-15 * v.getNorm()); Assert.assertEquals(pzDot.value(dt), v.getZ(), 1.0e-15 * v.getNorm()); Assert.assertEquals(pxDotDot.value(dt), a.getX(), 1.0e-14 * a.getNorm()); Assert.assertEquals(pyDotDot.value(dt), a.getY(), 1.0e-14 * a.getNorm()); Assert.assertEquals(pzDotDot.value(dt), a.getZ(), 1.0e-14 * a.getNorm()); } } }
From source file:org.orekit.utils.TimeStampedPVCoordinates.java
/** Interpolate position-velocity. * <p>/*from w ww . j ava 2 s. co m*/ * The interpolated instance is created by polynomial Hermite interpolation * ensuring velocity remains the exact derivative of position. * </p> * <p> * Note that even if first time derivatives (velocities) * from sample can be ignored, the interpolated instance always includes * interpolated derivatives. This feature can be used explicitly to * compute these derivatives when it would be too complex to compute them * from an analytical formula: just compute a few sample points from the * explicit formula and set the derivatives to zero in these sample points, * then use interpolation to add derivatives consistent with the positions. * </p> * @param date interpolation date * @param filter filter for derivatives from the sample to use in interpolation * @param sample sample points on which interpolation should be done * @return a new position-velocity, interpolated at specified date */ public static TimeStampedPVCoordinates interpolate(final AbsoluteDate date, final CartesianDerivativesFilter filter, final Collection<TimeStampedPVCoordinates> sample) { // set up an interpolator taking derivatives into account final HermiteInterpolator interpolator = new HermiteInterpolator(); // add sample points switch (filter) { case USE_P: // populate sample with position data, ignoring velocity for (final TimeStampedPVCoordinates pv : sample) { final Vector3D position = pv.getPosition(); interpolator.addSamplePoint(pv.getDate().durationFrom(date), new double[] { position.getX(), position.getY(), position.getZ() }); } break; case USE_PV: // populate sample with position and velocity data for (final TimeStampedPVCoordinates pv : sample) { final Vector3D position = pv.getPosition(); final Vector3D velocity = pv.getVelocity(); interpolator.addSamplePoint(pv.getDate().durationFrom(date), new double[] { position.getX(), position.getY(), position.getZ() }, new double[] { velocity.getX(), velocity.getY(), velocity.getZ() }); } break; case USE_PVA: // populate sample with position, velocity and acceleration data for (final TimeStampedPVCoordinates pv : sample) { final Vector3D position = pv.getPosition(); final Vector3D velocity = pv.getVelocity(); final Vector3D acceleration = pv.getAcceleration(); interpolator.addSamplePoint(pv.getDate().durationFrom(date), new double[] { position.getX(), position.getY(), position.getZ() }, new double[] { velocity.getX(), velocity.getY(), velocity.getZ() }, new double[] { acceleration.getX(), acceleration.getY(), acceleration.getZ() }); } break; default: // this should never happen throw new OrekitInternalError(null); } // interpolate final DerivativeStructure zero = new DerivativeStructure(1, 2, 0, 0.0); final DerivativeStructure[] p = interpolator.value(zero); // build a new interpolated instance return new TimeStampedPVCoordinates(date, new Vector3D(p[0].getValue(), p[1].getValue(), p[2].getValue()), new Vector3D(p[0].getPartialDerivative(1), p[1].getPartialDerivative(1), p[2].getPartialDerivative(1)), new Vector3D(p[0].getPartialDerivative(2), p[1].getPartialDerivative(2), p[2].getPartialDerivative(2))); }
From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java
@Test public void testToDerivativeStructureVector2() throws OrekitException { FieldVector3D<DerivativeStructure> fv = new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)) .toDerivativeStructureVector(2); Assert.assertEquals(1, fv.getX().getFreeParameters()); Assert.assertEquals(2, fv.getX().getOrder()); Assert.assertEquals(1.0, fv.getX().getReal(), 1.0e-10); Assert.assertEquals(0.1, fv.getY().getReal(), 1.0e-10); Assert.assertEquals(10.0, fv.getZ().getReal(), 1.0e-10); Assert.assertEquals(-1.0, fv.getX().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(-0.1, fv.getY().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(-10.0, fv.getZ().getPartialDerivative(1), 1.0e-15); Assert.assertEquals(10.0, fv.getX().getPartialDerivative(2), 1.0e-15); Assert.assertEquals(-1.0, fv.getY().getPartialDerivative(2), 1.0e-15); Assert.assertEquals(-100.0, fv.getZ().getPartialDerivative(2), 1.0e-15); checkPV(new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)), new TimeStampedPVCoordinates(AbsoluteDate.GALILEO_EPOCH, fv), 1.0e-15); for (double dt = 0; dt < 10; dt += 0.125) { Vector3D p = new PVCoordinates(new Vector3D(1, 0.1, 10), new Vector3D(-1, -0.1, -10), new Vector3D(10, -1.0, -100)).shiftedBy(dt).getPosition(); Assert.assertEquals(p.getX(), fv.getX().taylor(dt), 1.0e-14); Assert.assertEquals(p.getY(), fv.getY().taylor(dt), 1.0e-14); Assert.assertEquals(p.getZ(), fv.getZ().taylor(dt), 1.0e-14); }/*w w w .j av a 2 s . c om*/ }
From source file:org.orekit.utils.TimeStampedPVCoordinatesTest.java
@Test public void testInterpolatePolynomialPVA() { Random random = new Random(0xfe3945fcb8bf47cel); AbsoluteDate t0 = AbsoluteDate.J2000_EPOCH; for (int i = 0; i < 20; ++i) { PolynomialFunction px = randomPolynomial(5, random); PolynomialFunction py = randomPolynomial(5, random); PolynomialFunction pz = randomPolynomial(5, random); PolynomialFunction pxDot = px.polynomialDerivative(); PolynomialFunction pyDot = py.polynomialDerivative(); PolynomialFunction pzDot = pz.polynomialDerivative(); PolynomialFunction pxDotDot = pxDot.polynomialDerivative(); PolynomialFunction pyDotDot = pyDot.polynomialDerivative(); PolynomialFunction pzDotDot = pzDot.polynomialDerivative(); List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>(); for (double dt : new double[] { 0.0, 0.5, 1.0 }) { Vector3D position = new Vector3D(px.value(dt), py.value(dt), pz.value(dt)); Vector3D velocity = new Vector3D(pxDot.value(dt), pyDot.value(dt), pzDot.value(dt)); Vector3D acceleration = new Vector3D(pxDotDot.value(dt), pyDotDot.value(dt), pzDotDot.value(dt)); sample.add(new TimeStampedPVCoordinates(t0.shiftedBy(dt), position, velocity, acceleration)); }//from w w w. ja v a2 s . c o m for (double dt = 0; dt < 1.0; dt += 0.01) { TimeStampedPVCoordinates interpolated = TimeStampedPVCoordinates.interpolate(t0.shiftedBy(dt), CartesianDerivativesFilter.USE_PVA, sample); Vector3D p = interpolated.getPosition(); Vector3D v = interpolated.getVelocity(); Vector3D a = interpolated.getAcceleration(); Assert.assertEquals(px.value(dt), p.getX(), 4.0e-16 * p.getNorm()); Assert.assertEquals(py.value(dt), p.getY(), 4.0e-16 * p.getNorm()); Assert.assertEquals(pz.value(dt), p.getZ(), 4.0e-16 * p.getNorm()); Assert.assertEquals(pxDot.value(dt), v.getX(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pyDot.value(dt), v.getY(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pzDot.value(dt), v.getZ(), 9.0e-16 * v.getNorm()); Assert.assertEquals(pxDotDot.value(dt), a.getX(), 9.0e-15 * a.getNorm()); Assert.assertEquals(pyDotDot.value(dt), a.getY(), 9.0e-15 * a.getNorm()); Assert.assertEquals(pzDotDot.value(dt), a.getZ(), 9.0e-15 * a.getNorm()); } } }