{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Plane Gliding Example\n",
    "\n",
    "This example demonstrates how to use flight-mech to compute quantities for a gliding plane."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Python imports\n",
    "import os\n",
    "import sys\n",
    "sys.path.append(\"..\")\n",
    "\n",
    "# Additional imports\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# Flight-Mech imports\n",
    "from flight_mech.plane import Plane"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plane definition\n",
    "\n",
    "Let us use in this case the Cessna Citation III defined in the database."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load the plane\n",
    "plane = Plane(\"cessna_citation_III\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Gliding quantities\n",
    "\n",
    "We can now define an altitude and compute the range and the slope of the plane gliding at its maximum glide ratio."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Range max [m] 4984.282870844184\n",
      "gamma min [°] -3.4485871487092092\n"
     ]
    }
   ],
   "source": [
    "# Define the altitude\n",
    "z = 300\n",
    "\n",
    "# Print the results\n",
    "print(\"Range max [m]\", plane.compute_max_gliding_range(z))\n",
    "print(\"gamma min [°]\", plane.compute_min_descent_gliding_slope() * 180 / np.pi)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}