{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9c1800e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import batoid\n",
    "import numpy as np\n",
    "from ipywidgets import interact\n",
    "import ipywidgets as widgets\n",
    "import matplotlib.pyplot as plt\n",
    "from mpl_toolkits.mplot3d import Axes3D\n",
    "import ipyvolume as ipv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c12367a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "telescope = batoid.Optic.fromYaml(\"AuxTel.yaml\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f1812334",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "fig = plt.figure(figsize=(12, 11))\n",
    "ax = fig.add_subplot(111, projection='3d')\n",
    "telescope.draw3d(ax, c='k')\n",
    "\n",
    "fig = ipv.figure(width=700, height=500)\n",
    "telescope.draw3d(ipv, color='black')\n",
    "\n",
    "x = np.array([-0.4, -0.2, 0.2, 0.4])\n",
    "\n",
    "for vx, c in zip([-0.001, 0, 0.001], ['#377eb8', '#ff7f00', '#4daf4a']):\n",
    "    rays = batoid.RayVector(x, 0, 0, vx/1.000277, 0, -np.sqrt(1-vx**2)/1.000277, wavelength=620e-9)\n",
    "    rays.propagate(-telescope.backDist)\n",
    "    tF = telescope.traceFull(rays)\n",
    "    batoid.drawTrace3d(ax, tF, c=c)\n",
    "    batoid.drawTrace3d(ipv, tF, color=c)\n",
    "ax.set_xlim(-1.5, 1.5)\n",
    "ax.set_ylim(-1.5, 1.5)\n",
    "ax.set_zlim(-1, 2)\n",
    "ipv.xlim(-2, 2)\n",
    "ipv.ylim(-2, 2)\n",
    "ipv.zlim(-1, 3)\n",
    "ipv.show()\n",
    "ipv.view(azimuth=270, elevation=180, distance=1.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e28ce607-b40c-4273-8a02-3320ab031fab",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
