List of usage examples for org.apache.commons.math3.geometry.euclidean.threed FieldVector3D toArray
public T[] toArray()
From source file:org.orekit.utils.TimeStampedFieldPVCoordinates.java
/** Interpolate position-velocity. * <p>/*from w w w . j a va 2 s. com*/ * 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 * @param <T> the type of the field elements * @return a new position-velocity, interpolated at specified date */ @SuppressWarnings("unchecked") public static <T extends RealFieldElement<T>> TimeStampedFieldPVCoordinates<T> interpolate( final AbsoluteDate date, final CartesianDerivativesFilter filter, final Collection<TimeStampedFieldPVCoordinates<T>> sample) { // get field properties final T prototype = sample.iterator().next().getPosition().getX(); final T zero = prototype.getField().getZero(); // set up an interpolator taking derivatives into account final FieldHermiteInterpolator<T> interpolator = new FieldHermiteInterpolator<T>(); // add sample points switch (filter) { case USE_P: // populate sample with position data, ignoring velocity for (final TimeStampedFieldPVCoordinates<T> datedPV : sample) { final FieldVector3D<T> position = datedPV.getPosition(); interpolator.addSamplePoint(zero.add(datedPV.getDate().durationFrom(date)), position.toArray()); } break; case USE_PV: // populate sample with position and velocity data for (final TimeStampedFieldPVCoordinates<T> datedPV : sample) { final FieldVector3D<T> position = datedPV.getPosition(); final FieldVector3D<T> velocity = datedPV.getVelocity(); interpolator.addSamplePoint(zero.add(datedPV.getDate().durationFrom(date)), position.toArray(), velocity.toArray()); } break; case USE_PVA: // populate sample with position, velocity and acceleration data for (final TimeStampedFieldPVCoordinates<T> datedPV : sample) { final FieldVector3D<T> position = datedPV.getPosition(); final FieldVector3D<T> velocity = datedPV.getVelocity(); final FieldVector3D<T> acceleration = datedPV.getAcceleration(); interpolator.addSamplePoint(zero.add(datedPV.getDate().durationFrom(date)), position.toArray(), velocity.toArray(), acceleration.toArray()); } break; default: // this should never happen throw new OrekitInternalError(null); } // interpolate final T[][] p = interpolator.derivatives(zero, 2); // build a new interpolated instance return new TimeStampedFieldPVCoordinates<T>(date, new FieldVector3D<T>(p[0]), new FieldVector3D<T>(p[1]), new FieldVector3D<T>(p[2])); }