Skip to content

Commit

Permalink
feat: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwa2710 committed Jun 25, 2024
1 parent f72d66b commit 2d15336
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,12 @@ Array<Pass> Orbit::ComputePassesWithModel(

while (true)
{
if ((isForwardPropagated && (previousInstant >= anEndInstant)) ||
(!isForwardPropagated && (previousInstant <= anEndInstant)))
{
break;
}

std::tie(northPointCrossing, descendingNodeCrossing, southPointCrossing, passBreakCrossing) =
Orbit::ComputeCrossings(aModel, previousInstant, stepDuration, isForwardPropagated, anEndInstant);

Expand All @@ -1235,6 +1241,15 @@ Array<Pass> Orbit::ComputePassesWithModel(

passes.add(pass);

// if forward propagating and the pass has an undefined PassBreak, then we have crossed the end of the interval
// if backward propagating and the pass has an undefined AscendingNode, then we have crossed the end of the
// interval
if ((isForwardPropagated && !pass.accessInstantAtPassBreak().isDefined()) ||
(!isForwardPropagated && !pass.accessInstantAtAscendingNode().isDefined()))
{
break;
}

revolutionNumber += isForwardPropagated ? 1 : -1;
previousPassEndInstant = passBreakCrossing;

Expand All @@ -1249,15 +1264,6 @@ Array<Pass> Orbit::ComputePassesWithModel(
stepDuration = *std::min_element(durations.begin(), durations.end()) / 2.0;
}

// if forward propagating and the pass has an undefined PassBreak, then we have crossed the end of the interval
// if backward propagating and the pass has an undefined AscendingNode, then we have crossed the end of the
// interval
if ((isForwardPropagated && !pass.accessInstantAtPassBreak().isDefined()) ||
(!isForwardPropagated && !pass.accessInstantAtAscendingNode().isDefined()))
{
break;
}

previousInstant = isForwardPropagated ? pass.accessInstantAtPassBreak() + Duration::Microseconds(1.0)
: pass.accessInstantAtAscendingNode() - Duration::Microseconds(1.0);
}
Expand Down Expand Up @@ -1296,6 +1302,11 @@ Tuple<Instant, Instant, Instant, Instant> Orbit::ComputeCrossings(
Instant descendingNodeCrossing = Instant::Undefined();
Instant passBreakCrossing = Instant::Undefined();

if (anEndInstant.isDefined() && (previousInstant >= anEndInstant))
{
return {northPointCrossing, descendingNodeCrossing, southPointCrossing, passBreakCrossing};
}

const Instant epoch = aModel.getEpoch();

const State previousState = aModel.calculateStateAt(previousInstant);
Expand Down

0 comments on commit 2d15336

Please sign in to comment.