Commit 0c80ce7b authored by Bryan Cazabonne's avatar Bryan Cazabonne
Browse files

TabulateLofOffset now implements BoundedAttitudeProvider.

Fixes #762
parent 6d834ee0
......@@ -46,7 +46,7 @@ import org.orekit.utils.TimeStampedFieldAngularCoordinates;
* @author Luc Maisonobe
* @since 7.1
*/
public class TabulatedLofOffset implements AttitudeProvider {
public class TabulatedLofOffset implements BoundedAttitudeProvider {
/** Inertial frame with respect to which orbit should be computed. */
private final Frame inertialFrame;
......@@ -55,12 +55,21 @@ public class TabulatedLofOffset implements AttitudeProvider {
private LOFType type;
/** Cached attitude table. */
private final transient ImmutableTimeStampedCache<TimeStampedAngularCoordinates> table;
private final transient ImmutableTimeStampedCache<? extends TimeStampedAngularCoordinates> table;
/** Filter for derivatives from the sample to use in interpolation. */
private final AngularDerivativesFilter filter;
/** First date of the range. */
private final AbsoluteDate minDate;
/** Last date of the range. */
private final AbsoluteDate maxDate;
/** Creates new instance.
* <p>
* This constructor uses the first and last point samples as the min and max dates.
* </p>
* @param inertialFrame inertial frame with respect to which orbit should be computed
* @param type type of Local Orbital Frame
* @param table tabulated attitudes
......@@ -68,8 +77,25 @@ public class TabulatedLofOffset implements AttitudeProvider {
* @param filter filter for derivatives from the sample to use in interpolation
*/
public TabulatedLofOffset(final Frame inertialFrame, final LOFType type,
final List<TimeStampedAngularCoordinates> table,
final List<? extends TimeStampedAngularCoordinates> table,
final int n, final AngularDerivativesFilter filter) {
this(inertialFrame, type, table, n, filter, table.get(0).getDate(), table.get(table.size() - 1).getDate());
}
/** Creates new instance.
* @param inertialFrame inertial frame with respect to which orbit should be computed
* @param type type of Local Orbital Frame
* @param table tabulated attitudes
* @param n number of attitude to use for interpolation
* @param minDate min date to use
* @param maxDate max date to use
* @param filter filter for derivatives from the sample to use in interpolation
* @since 11.0
*/
public TabulatedLofOffset(final Frame inertialFrame, final LOFType type,
final List<? extends TimeStampedAngularCoordinates> table,
final int n, final AngularDerivativesFilter filter,
final AbsoluteDate minDate, final AbsoluteDate maxDate) {
if (!inertialFrame.isPseudoInertial()) {
throw new OrekitException(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME,
inertialFrame.getName());
......@@ -78,12 +104,14 @@ public class TabulatedLofOffset implements AttitudeProvider {
this.type = type;
this.table = new ImmutableTimeStampedCache<TimeStampedAngularCoordinates>(n, table);
this.filter = filter;
this.minDate = minDate;
this.maxDate = maxDate;
}
/** Get an unmodifiable view of the tabulated attitudes.
* @return unmodifiable view of the tabulated attitudes
*/
public List<TimeStampedAngularCoordinates> getTable() {
public List<? extends TimeStampedAngularCoordinates> getTable() {
return table.getAll();
}
......@@ -140,4 +168,14 @@ public class TabulatedLofOffset implements AttitudeProvider {
interpolated.addOffset(frameToLof.getAngular()));
}
/** {@inheritDoc} */
public AbsoluteDate getMinDate() {
return minDate;
}
/** {@inheritDoc} */
public AbsoluteDate getMaxDate() {
return maxDate;
}
}
......@@ -39,6 +39,7 @@ import org.junit.Test;
import org.orekit.Utils;
import org.orekit.bodies.OneAxisEllipsoid;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
import org.orekit.frames.Frame;
import org.orekit.frames.FramesFactory;
import org.orekit.frames.LOFType;
......@@ -112,7 +113,7 @@ public class TabulatedLofOffsetTest {
2, AngularDerivativesFilter.USE_R);
Rotation rebuilt = tabulated.getAttitude(orbit, orbit.getDate(), orbit.getFrame()).getRotation();
Assert.assertEquals(0.0, Rotation.distance(offsetAtt, rebuilt), 1.2e-15);
Assert.assertEquals(3, tabulated.getTable().size());
}
}
}
......@@ -139,12 +140,15 @@ public class TabulatedLofOffsetTest {
offsetProper, Vector3D.ZERO, Vector3D.ZERO));
}
});
originalPropagator.propagate(orbit.getDate().shiftedBy(2000));
final AbsoluteDate endDate = orbit.getDate().shiftedBy(2000);
originalPropagator.propagate(endDate);
originalPropagator.setSlaveMode();
// use the sample and compare it to original
final AttitudeProvider tabulated = new TabulatedLofOffset(orbit.getFrame(), type, sample,
6, AngularDerivativesFilter.USE_RR);
final BoundedAttitudeProvider tabulated = new TabulatedLofOffset(orbit.getFrame(), type, sample,
6, AngularDerivativesFilter.USE_RR);
Assert.assertEquals(0., orbit.getDate().durationFrom(tabulated.getMinDate()), Double.MIN_VALUE);
Assert.assertEquals(0., endDate.durationFrom(tabulated.getMaxDate()), Double.MIN_VALUE);
final Propagator rebuildingPropagator = new KeplerianPropagator(orbit);
rebuildingPropagator.setAttitudeProvider(tabulated);
rebuildingPropagator.setMasterMode(0.3, new OrekitFixedStepHandler() {
......@@ -175,6 +179,24 @@ public class TabulatedLofOffsetTest {
Assert.assertEquals(0.0, Vector3D.distance(attitudeD.getRotationAcceleration(), attitudeF.getRotationAcceleration().toVector3D()), 1.0e-15);
}
@Test
public void testNonPseudoInertialFrame() {
final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
try {
new TabulatedLofOffset(itrf, LOFType.QSW,
Arrays.asList(new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(-10),
Rotation.IDENTITY, Vector3D.ZERO, Vector3D.ZERO),
new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(0),
Rotation.IDENTITY, Vector3D.ZERO, Vector3D.ZERO),
new TimeStampedAngularCoordinates(orbit.getDate().shiftedBy(+10),
Rotation.IDENTITY, Vector3D.ZERO, Vector3D.ZERO)),
2, AngularDerivativesFilter.USE_R);
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, oe.getSpecifier());
Assert.assertEquals(itrf.getName(), oe.getParts()[0]);
}
}
@Before
public void setUp() {
try {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment