"""Lecture 34, skips from 80 km at 7.8 km/s of the representative glider (B = 300 kg/m^2, L/D = 1) at 3, 5 and 8 deg:
height against distance, and the flight-path angle against time. Dashed lines in the right panel: the first-order exit
angle -gamma_i. Writes img/fig-34-skip.png."""
import numpy as np
from _visual import plt, save, despine, MAROON, BLUE, GREEN
import _entry33 as X

CASES = [(-3.0, GREEN), (-5.0, BLUE), (-8.0, MAROON)]

if __name__ == "__main__":
    fig, (a, b) = plt.subplots(1, 2, figsize=(10, 4.4), gridspec_kw=dict(wspace=0.28))
    for g, c in CASES:
        s = X.skip(1.0, g)
        tr, k = s["tr"], slice(0, s["back"] + 1)
        a.plot(tr.downrange[k] / 1e3, tr.h[k] / 1e3, color=c, lw=2.4, label=f"entry {abs(g):.0f}°")
        b.plot(tr.t[k], np.degrees(tr.gamma[k]), color=c, lw=2.4)
        b.axhline(-g, color=c, lw=1, ls="--")
    a.set_xlabel("distance along the ground (km)"); a.set_ylabel("height (km)"); a.set_ylim(45, 82)
    b.set_xlabel("time (s)"); b.set_ylabel("flight-path angle (°)")
    despine(a); despine(b)
    fig.legend(*a.get_legend_handles_labels(), frameon=False, fontsize=11, ncol=3, loc="upper center", bbox_to_anchor=(0.5, 0.0))
    save(fig, "fig-34-skip")
