"""Lecture 10: schematic of a pitot tube mounted ahead of a light aircraft's wing, clear of the disturbed air close to
the surface and (on a single-engined propeller aircraft) of the propeller's slipstream. No numbers.
Writes img/fig-10-pitot-wing.png."""
from matplotlib.patches import Polygon, Ellipse, Rectangle
from _visual import plt, save, MAROON, BLUE, INK, GREY, AMBER

if __name__ == "__main__":
    fig, ax = plt.subplots(figsize=(10, 4.6))
    ax.add_patch(Ellipse((0, -0.9), 0.9, 4.4, facecolor="#e6e1d6", edgecolor=INK, lw=1.6))
    ax.add_patch(Polygon([(0.3, 0.2), (6.0, -0.05), (6.2, -0.35), (6.0, -1.35), (0.3, -1.35)], closed=True, facecolor="#e6e1d6", edgecolor=INK, lw=1.6))
    ax.add_patch(Rectangle((-1.3, 0.05), 2.6, 2.1, facecolor=AMBER, alpha=0.14, edgecolor="none"))
    ax.plot([-1.0, 1.0], [1.45, 1.45], color=INK, lw=4, solid_capstyle="round")
    ax.text(0, 1.75, "propeller", ha="center", fontsize=12); ax.text(-1.42, 0.7, "slipstream", ha="right", fontsize=12, color="#8a4a08")
    ax.plot([4.8, 4.8, 4.8], [-0.02, 0.55, 1.25], color=MAROON, lw=4, solid_capstyle="round")
    ax.annotate("pitot tube, ahead of the wing\nand pointing into the flow", (4.8, 0.95), xytext=(3.9, -2.15), fontsize=12.5, color=MAROON, ha="center",
                arrowprops=dict(arrowstyle="->", color=MAROON))
    for x in (6.9, 7.4, 7.9):
        ax.annotate("", xy=(x, -0.2), xytext=(x, 1.6), arrowprops=dict(arrowstyle="-|>", color=BLUE, lw=2))
    ax.text(7.4, 1.85, "oncoming air", ha="center", fontsize=12, color=BLUE)
    ax.text(2.0, -0.75, "wing, seen from above", ha="center", fontsize=12.5)
    ax.set_xlim(-3.0, 8.6); ax.set_ylim(-3.2, 2.2); ax.set_aspect("equal"); ax.axis("off")
    save(fig, "fig-10-pitot-wing")
