Fix: recompute sun-frame trail and SOI crossings after flyby
After SOI exit the asteroid has new orbital elements (gravity assist). Previously the old trail and crossing predictions were never updated, causing three bugs: 1. Old trajectory still drawn after exit 2. Next SOI entry time based on stale orbit 3. Subsequent SOI entries never triggered Now on exit: recompute trail, rescans for future SOI crossings, and resets the crossing index.
This commit is contained in:
@@ -247,15 +247,24 @@ def main() -> None:
|
|||||||
asteroid_planet = None
|
asteroid_planet = None
|
||||||
soi_exit_time = None
|
soi_exit_time = None
|
||||||
|
|
||||||
# Advance to next crossing
|
# ── Recompute trail from new sun orbit ──────
|
||||||
cross_idx += 1
|
trail_asteroid_sun = [
|
||||||
while cross_idx < len(sun_crossings):
|
to_screen(x, y) for x, y in
|
||||||
if sun_crossings[cross_idx][0] > sim_time + 0.1:
|
generate_orbit_points(asteroid_sun)
|
||||||
soi_enter_time = sun_crossings[cross_idx][0]
|
]
|
||||||
break
|
|
||||||
cross_idx += 1
|
# ── Recompute future SOI crossings ───────────
|
||||||
else:
|
window = SEARCH_ORBITS * max(asteroid_sun.period, PLANET.period)
|
||||||
soi_enter_time = None
|
sun_crossings = find_soi_crossings(
|
||||||
|
asteroid_sun, PLANET, SOI_RADIUS,
|
||||||
|
sim_time + 0.1, sim_time + window, n_steps=1000,
|
||||||
|
)
|
||||||
|
print(f" Re-scanned: found {len(sun_crossings)} future crossing(s)")
|
||||||
|
for i, (enter, _) in enumerate(sun_crossings):
|
||||||
|
print(f" [{i}] enter={enter:.1f}s")
|
||||||
|
|
||||||
|
cross_idx = 0
|
||||||
|
soi_enter_time = sun_crossings[0][0] if sun_crossings else None
|
||||||
|
|
||||||
# ── Compute current positions ──────────────────────
|
# ── Compute current positions ──────────────────────
|
||||||
px, py = PLANET.position_at(sim_time)
|
px, py = PLANET.position_at(sim_time)
|
||||||
|
|||||||
Reference in New Issue
Block a user