Browse Source

fix the case where step passes through 0 in testManeuverStep()

main
cinnaboot 4 years ago
parent
commit
fd868b0f45
  1. 20
      src/game.cpp

20
src/game.cpp

@ -196,15 +196,21 @@ testManeuverStep(const ManeuverNode& maneuver,
if (!maneuver.active) if (!maneuver.active)
return false; return false;
double r = maneuver.true_anomaly; // NOTE: clamp angles between 0 and 2 pi to simplify inequalities
previous_theta = orbitClampAngle(previous_theta); double r = orbitClampAngle(maneuver.true_anomaly);
next_theta = orbitClampAngle(next_theta); double clamped_previous_theta = orbitClampAngle(previous_theta);
double clamped_next_theta = orbitClampAngle(next_theta);
// FIXME: 2 unhandled cases: // FIXME: unhandled cases:
// 1) sat passes through 0 degrees
// 2) direction is ccw // 2) direction is ccw
//
if (previous_theta <= r && next_theta >= r) // NOTE: sat passess through 0
if (clamped_next_theta - clamped_previous_theta < 0) {
if (r >= clamped_previous_theta || r <= clamped_next_theta)
return true;
}
else if (r >= clamped_previous_theta && r <= clamped_next_theta)
return true; return true;
return false; return false;

Loading…
Cancel
Save