TimeStampedFieldPVCoordinates.java
/* Copyright 2002-2020 CS Group
* Licensed to CS Group (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.utils;
import java.util.Collection;
import java.util.stream.Stream;
import org.hipparchus.RealFieldElement;
import org.hipparchus.analysis.differentiation.FieldDerivativeStructure;
import org.hipparchus.analysis.interpolation.FieldHermiteInterpolator;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.orekit.annotation.DefaultDataContext;
import org.orekit.data.DataContext;
import org.orekit.errors.OrekitInternalError;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
import org.orekit.time.TimeScale;
import org.orekit.time.TimeStamped;
/** {@link TimeStamped time-stamped} version of {@link FieldPVCoordinates}.
* <p>Instances of this class are guaranteed to be immutable.</p>
* @param <T> the type of the field elements
* @author Luc Maisonobe
* @since 7.0
*/
public class TimeStampedFieldPVCoordinates<T extends RealFieldElement<T>>
extends FieldPVCoordinates<T> {
/** The date. */
private final FieldAbsoluteDate<T> date;
/** Builds a PVCoordinates pair.
* @param date coordinates date
* @param position the position vector (m)
* @param velocity the velocity vector (m/s)
* @param acceleration the acceleration vector (m/s²)
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final FieldVector3D<T> position,
final FieldVector3D<T> velocity,
final FieldVector3D<T> acceleration) {
this(new FieldAbsoluteDate<>(position.getX().getField(), date),
position, velocity, acceleration);
}
/** Builds a PVCoordinates pair.
* @param date coordinates date
* @param position the position vector (m)
* @param velocity the velocity vector (m/s)
* @param acceleration the acceleration vector (m/s²)
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final FieldVector3D<T> position,
final FieldVector3D<T> velocity,
final FieldVector3D<T> acceleration) {
super(position, velocity, acceleration);
this.date = date;
}
/** Basic constructor.
* <p>Build a PVCoordinates from another one at a given date</p>
* <p>The PVCoordinates built will be pv</p>
* @param date date of the built coordinates
* @param pv base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date, final FieldPVCoordinates<T> pv) {
this(new FieldAbsoluteDate<>(pv.getPosition().getX().getField(), date), pv);
}
/** Basic constructor.
* <p>Build a PVCoordinates from another one at a given date</p>
* <p>The PVCoordinates built will be pv</p>
* @param date date of the built coordinates
* @param pv base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date, final FieldPVCoordinates<T> pv) {
super(pv.getPosition(),
pv.getVelocity(),
pv.getAcceleration());
this.date = date;
}
/** Multiplicative constructor
* <p>Build a PVCoordinates from another one and a scale factor.</p>
* <p>The PVCoordinates built will be a * pv</p>
* @param date date of the built coordinates
* @param a scale factor
* @param pv base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final double a, final FieldPVCoordinates<T> pv) {
this(new FieldAbsoluteDate<>(pv.getPosition().getX().getField(), date), a, pv);
}
/** Multiplicative constructor
* <p>Build a PVCoordinates from another one and a scale factor.</p>
* <p>The PVCoordinates built will be a * pv</p>
* @param date date of the built coordinates
* @param a scale factor
* @param pv base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final double a, final FieldPVCoordinates<T> pv) {
super(new FieldVector3D<>(a, pv.getPosition()),
new FieldVector3D<>(a, pv.getVelocity()),
new FieldVector3D<>(a, pv.getAcceleration()));
this.date = date;
}
/** Multiplicative constructor
* <p>Build a PVCoordinates from another one and a scale factor.</p>
* <p>The PVCoordinates built will be a * pv</p>
* @param date date of the built coordinates
* @param a scale factor
* @param pv base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final T a, final FieldPVCoordinates<T> pv) {
this(new FieldAbsoluteDate<>(a.getField(), date), a, pv);
}
/** Multiplicative constructor
* <p>Build a PVCoordinates from another one and a scale factor.</p>
* <p>The PVCoordinates built will be a * pv</p>
* @param date date of the built coordinates
* @param a scale factor
* @param pv base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final T a, final FieldPVCoordinates<T> pv) {
super(new FieldVector3D<>(a, pv.getPosition()),
new FieldVector3D<>(a, pv.getVelocity()),
new FieldVector3D<>(a, pv.getAcceleration()));
this.date = date;
}
/** Multiplicative constructor
* <p>Build a PVCoordinates from another one and a scale factor.</p>
* <p>The PVCoordinates built will be a * pv</p>
* @param date date of the built coordinates
* @param a scale factor
* @param pv base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final T a, final PVCoordinates pv) {
this(new FieldAbsoluteDate<>(a.getField(), date), a, pv);
}
/** Multiplicative constructor
* <p>Build a PVCoordinates from another one and a scale factor.</p>
* <p>The PVCoordinates built will be a * pv</p>
* @param date date of the built coordinates
* @param a scale factor
* @param pv base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final T a, final PVCoordinates pv) {
super(new FieldVector3D<>(a, pv.getPosition()),
new FieldVector3D<>(a, pv.getVelocity()),
new FieldVector3D<>(a, pv.getAcceleration()));
this.date = date;
}
/** Subtractive constructor
* <p>Build a relative PVCoordinates from a start and an end position.</p>
* <p>The PVCoordinates built will be end - start.</p>
* @param date date of the built coordinates
* @param start Starting PVCoordinates
* @param end ending PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final FieldPVCoordinates<T> start, final FieldPVCoordinates<T> end) {
this(new FieldAbsoluteDate<>(start.getPosition().getX().getField(), date), start, end);
}
/** Subtractive constructor
* <p>Build a relative PVCoordinates from a start and an end position.</p>
* <p>The PVCoordinates built will be end - start.</p>
* @param date date of the built coordinates
* @param start Starting PVCoordinates
* @param end ending PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final FieldPVCoordinates<T> start, final FieldPVCoordinates<T> end) {
super(end.getPosition().subtract(start.getPosition()),
end.getVelocity().subtract(start.getVelocity()),
end.getAcceleration().subtract(start.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final double a1, final FieldPVCoordinates<T> pv1,
final double a2, final FieldPVCoordinates<T> pv2) {
this(new FieldAbsoluteDate<>(pv1.getPosition().getX().getField(), date),
a1, pv1, a2, pv2);
}
/** Linear constructor
* <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final double a1, final FieldPVCoordinates<T> pv1,
final double a2, final FieldPVCoordinates<T> pv2) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final T a1, final FieldPVCoordinates<T> pv1,
final T a2, final FieldPVCoordinates<T> pv2) {
this(new FieldAbsoluteDate<>(a1.getField(), date),
a1, pv1, a2, pv2);
}
/** Linear constructor
* <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final T a1, final FieldPVCoordinates<T> pv1,
final T a2, final FieldPVCoordinates<T> pv2) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final T a1, final PVCoordinates pv1,
final T a2, final PVCoordinates pv2) {
this(new FieldAbsoluteDate<>(a1.getField(), date),
a1, pv1, a2, pv2);
}
/** Linear constructor
* <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final T a1, final PVCoordinates pv1,
final T a2, final PVCoordinates pv2) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final double a1, final FieldPVCoordinates<T> pv1,
final double a2, final FieldPVCoordinates<T> pv2,
final double a3, final FieldPVCoordinates<T> pv3) {
this(new FieldAbsoluteDate<>(pv1.getPosition().getX().getField(), date),
a1, pv1, a2, pv2, a3, pv3);
}
/** Linear constructor
* <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final double a1, final FieldPVCoordinates<T> pv1,
final double a2, final FieldPVCoordinates<T> pv2,
final double a3, final FieldPVCoordinates<T> pv3) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition(), a3, pv3.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity(), a3, pv3.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration(), a3, pv3.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final T a1, final FieldPVCoordinates<T> pv1,
final T a2, final FieldPVCoordinates<T> pv2,
final T a3, final FieldPVCoordinates<T> pv3) {
this(new FieldAbsoluteDate<>(a1.getField(), date),
a1, pv1, a2, pv2, a3, pv3);
}
/** Linear constructor
* <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final T a1, final FieldPVCoordinates<T> pv1,
final T a2, final FieldPVCoordinates<T> pv2,
final T a3, final FieldPVCoordinates<T> pv3) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition(), a3, pv3.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity(), a3, pv3.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration(), a3, pv3.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final T a1, final PVCoordinates pv1,
final T a2, final PVCoordinates pv2,
final T a3, final PVCoordinates pv3) {
this(new FieldAbsoluteDate<>(a1.getField(), date),
a1, pv1, a2, pv2, a3, pv3);
}
/** Linear constructor
* <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final T a1, final PVCoordinates pv1,
final T a2, final PVCoordinates pv2,
final T a3, final PVCoordinates pv3) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition(), a3, pv3.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity(), a3, pv3.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration(), a3, pv3.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
* @param a4 fourth scale factor
* @param pv4 fourth base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final double a1, final FieldPVCoordinates<T> pv1,
final double a2, final FieldPVCoordinates<T> pv2,
final double a3, final FieldPVCoordinates<T> pv3,
final double a4, final FieldPVCoordinates<T> pv4) {
this(new FieldAbsoluteDate<>(pv1.getPosition().getX().getField(), date),
a1, pv1, a2, pv2, a3, pv3, a4, pv4);
}
/** Linear constructor
* <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
* @param a4 fourth scale factor
* @param pv4 fourth base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final double a1, final FieldPVCoordinates<T> pv1,
final double a2, final FieldPVCoordinates<T> pv2,
final double a3, final FieldPVCoordinates<T> pv3,
final double a4, final FieldPVCoordinates<T> pv4) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition(),
a3, pv3.getPosition(), a4, pv4.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity(),
a3, pv3.getVelocity(), a4, pv4.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration(),
a3, pv3.getAcceleration(), a4, pv4.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
* @param a4 fourth scale factor
* @param pv4 fourth base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final T a1, final FieldPVCoordinates<T> pv1,
final T a2, final FieldPVCoordinates<T> pv2,
final T a3, final FieldPVCoordinates<T> pv3,
final T a4, final FieldPVCoordinates<T> pv4) {
this(new FieldAbsoluteDate<>(a1.getField(), date),
a1, pv1, a2, pv2, a3, pv3, a4, pv4);
}
/** Linear constructor
* <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
* @param a4 fourth scale factor
* @param pv4 fourth base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final T a1, final FieldPVCoordinates<T> pv1,
final T a2, final FieldPVCoordinates<T> pv2,
final T a3, final FieldPVCoordinates<T> pv3,
final T a4, final FieldPVCoordinates<T> pv4) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition(),
a3, pv3.getPosition(), a4, pv4.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity(),
a3, pv3.getVelocity(), a4, pv4.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration(),
a3, pv3.getAcceleration(), a4, pv4.getAcceleration()));
this.date = date;
}
/** Linear constructor
* <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
* @param a4 fourth scale factor
* @param pv4 fourth base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final AbsoluteDate date,
final T a1, final PVCoordinates pv1,
final T a2, final PVCoordinates pv2,
final T a3, final PVCoordinates pv3,
final T a4, final PVCoordinates pv4) {
this(new FieldAbsoluteDate<>(a1.getField(), date),
a1, pv1, a2, pv2, a3, pv3, a4, pv4);
}
/** Linear constructor
* <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
* <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
* @param date date of the built coordinates
* @param a1 first scale factor
* @param pv1 first base (unscaled) PVCoordinates
* @param a2 second scale factor
* @param pv2 second base (unscaled) PVCoordinates
* @param a3 third scale factor
* @param pv3 third base (unscaled) PVCoordinates
* @param a4 fourth scale factor
* @param pv4 fourth base (unscaled) PVCoordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final T a1, final PVCoordinates pv1,
final T a2, final PVCoordinates pv2,
final T a3, final PVCoordinates pv3,
final T a4, final PVCoordinates pv4) {
super(new FieldVector3D<>(a1, pv1.getPosition(), a2, pv2.getPosition(),
a3, pv3.getPosition(), a4, pv4.getPosition()),
new FieldVector3D<>(a1, pv1.getVelocity(), a2, pv2.getVelocity(),
a3, pv3.getVelocity(), a4, pv4.getVelocity()),
new FieldVector3D<>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration(),
a3, pv3.getAcceleration(), a4, pv4.getAcceleration()));
this.date = date;
}
/** Builds a TimeStampedFieldPVCoordinates triplet from a {@link FieldVector3D}<{@link FieldDerivativeStructure}>.
* <p>
* The vector components must have time as their only derivation parameter and
* have consistent derivation orders.
* </p>
* @param date date of the built coordinates
* @param p vector with time-derivatives embedded within the coordinates
*/
public TimeStampedFieldPVCoordinates(final FieldAbsoluteDate<T> date,
final FieldVector3D<FieldDerivativeStructure<T>> p) {
super(p);
this.date = date;
}
/** Get the date.
* @return date
*/
public FieldAbsoluteDate<T> getDate() {
return date;
}
/** Get a time-shifted state.
* <p>
* The state can be slightly shifted to close dates. This shift is based on
* a simple linear model. It is <em>not</em> intended as a replacement for
* proper orbit propagation (it is not even Keplerian!) but should be sufficient
* for either small time shifts or coarse accuracy.
* </p>
* @param dt time shift in seconds
* @return a new state, shifted with respect to the instance (which is immutable)
*/
public TimeStampedFieldPVCoordinates<T> shiftedBy(final double dt) {
final FieldPVCoordinates<T> spv = super.shiftedBy(dt);
return new TimeStampedFieldPVCoordinates<>(date.shiftedBy(dt),
spv.getPosition(), spv.getVelocity(), spv.getAcceleration());
}
/** Get a time-shifted state.
* <p>
* The state can be slightly shifted to close dates. This shift is based on
* a simple linear model. It is <em>not</em> intended as a replacement for
* proper orbit propagation (it is not even Keplerian!) but should be sufficient
* for either small time shifts or coarse accuracy.
* </p>
* @param dt time shift in seconds
* @return a new state, shifted with respect to the instance (which is immutable)
*/
public TimeStampedFieldPVCoordinates<T> shiftedBy(final T dt) {
final FieldPVCoordinates<T> spv = super.shiftedBy(dt);
return new TimeStampedFieldPVCoordinates<>(date.shiftedBy(dt),
spv.getPosition(), spv.getVelocity(), spv.getAcceleration());
}
/** Interpolate position-velocity.
* <p>
* 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
*/
public static <T extends RealFieldElement<T>>
TimeStampedFieldPVCoordinates<T> interpolate(final FieldAbsoluteDate<T> date,
final CartesianDerivativesFilter filter,
final Collection<TimeStampedFieldPVCoordinates<T>> sample) {
return interpolate(date, filter, sample.stream());
}
/** Interpolate position-velocity.
* <p>
* 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
*/
public static <T extends RealFieldElement<T>>
TimeStampedFieldPVCoordinates<T> interpolate(final FieldAbsoluteDate<T> date,
final CartesianDerivativesFilter filter,
final Stream<TimeStampedFieldPVCoordinates<T>> sample) {
// set up an interpolator taking derivatives into account
final FieldHermiteInterpolator<T> interpolator = new FieldHermiteInterpolator<>();
// add sample points
switch (filter) {
case USE_P :
// populate sample with position data, ignoring velocity
sample.forEach(pv -> {
final FieldVector3D<T> position = pv.getPosition();
interpolator.addSamplePoint(pv.getDate().durationFrom(date),
position.toArray());
});
break;
case USE_PV :
// populate sample with position and velocity data
sample.forEach(pv -> {
final FieldVector3D<T> position = pv.getPosition();
final FieldVector3D<T> velocity = pv.getVelocity();
interpolator.addSamplePoint(pv.getDate().durationFrom(date),
position.toArray(), velocity.toArray());
});
break;
case USE_PVA :
// populate sample with position, velocity and acceleration data
sample.forEach(pv -> {
final FieldVector3D<T> position = pv.getPosition();
final FieldVector3D<T> velocity = pv.getVelocity();
final FieldVector3D<T> acceleration = pv.getAcceleration();
interpolator.addSamplePoint(pv.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(date.getField().getZero(), 2);
// build a new interpolated instance
return new TimeStampedFieldPVCoordinates<>(date,
new FieldVector3D<>(p[0]),
new FieldVector3D<>(p[1]),
new FieldVector3D<>(p[2]));
}
/** Convert to a constant position-velocity.
* @return a constant position-velocity
* @since 9.0
*/
public TimeStampedPVCoordinates toTimeStampedPVCoordinates() {
return new TimeStampedPVCoordinates(date.toAbsoluteDate(),
getPosition().toVector3D(),
getVelocity().toVector3D(),
getAcceleration().toVector3D());
}
/** Return a string representation of this date, position, velocity, and acceleration.
*
* <p>This method uses the {@link DataContext#getDefault() default data context}.
*
* @return string representation of this.
*/
@Override
@DefaultDataContext
public String toString() {
return toTimeStampedPVCoordinates().toString();
}
/**
* Return a string representation of this date, position, velocity, and acceleration.
*
* @param utc time scale used to print the date.
* @return string representation of this.
*/
public String toString(final TimeScale utc) {
return toTimeStampedPVCoordinates().toString(utc);
}
}