use of org.orekit.propagation.events.FunctionalDetector.GFunction in project Orekit by CS-SI.
the class FunctionalDetectorTest method testFunctionalDetector.
/**
* Check {@link FunctionalDetector}.
*
* @throws OrekitException on error.
*/
@Test
public void testFunctionalDetector() throws OrekitException {
// setup
GFunction g = SpacecraftState::getMass;
EventHandler<EventDetector> handler = (s, detector, increasing) -> Action.STOP;
// action
FunctionalDetector detector = new FunctionalDetector().withMaxIter(1).withThreshold(2).withMaxCheck(3).withGFunction(g).withHandler(handler);
// verify
MatcherAssert.assertThat(detector.getMaxIterationCount(), CoreMatchers.is(1));
MatcherAssert.assertThat(detector.getThreshold(), CoreMatchers.is(2.0));
MatcherAssert.assertThat(detector.getMaxCheckInterval(), CoreMatchers.is(3.0));
MatcherAssert.assertThat(detector.getHandler(), CoreMatchers.is(handler));
MatcherAssert.assertThat(detector.getGFunction(), CoreMatchers.is(g));
SpacecraftState state = new SpacecraftState(new CartesianOrbit(new PVCoordinates(new Vector3D(1, 2, 3), new Vector3D(4, 5, 6)), FramesFactory.getGCRF(), AbsoluteDate.CCSDS_EPOCH, 4), 5);
MatcherAssert.assertThat(detector.g(state), CoreMatchers.is(5.0));
MatcherAssert.assertThat(detector.eventOccurred(null, false), CoreMatchers.is(Action.STOP));
}
Aggregations