{
 "nbformat": 4,
 "nbformat_minor": 5,
 "metadata": {
  "kernelspec": {
   "name": "python3",
   "language": "python",
   "display_name": "Python 3"
  },
  "language_info": {
   "name": "python"
  },
  "fundamentals": {
   "title": "Which path is shortest across the surface of a cone?",
   "lead": "A point can move along a conical surface while its azimuth and height both change. Unroll the geometry and predict the shortest path between two marked points. The measurable minimum radius distinguishes the geodesic from a line drawn along a horizontal circle.",
   "unit_slug": "geodesics-on-a-cone"
  }
 },
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9fcace5efb78",
   "metadata": {},
   "source": [
    "# Which path is shortest across the surface of a cone?\n",
    "\n",
    "A point can move along a conical surface while its azimuth and height both change. Unroll the geometry and predict the shortest path between two marked points. The measurable minimum radius distinguishes the geodesic from a line drawn along a horizontal circle."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e37ca6cff83a",
   "metadata": {
    "fundamentals": {
     "section": "derive-the-model"
    }
   },
   "source": [
    "## Turn the constraint into a distance measurement\n",
    "\n",
    "Let $r$ denote the slant distance from the apex and $\\alpha$ the angle between the cone's side and its central axis. A point at $r$ lies on a horizontal circle of radius $r\\sin\\alpha$. Small radial and azimuthal displacements on the surface meet at right angles. Their squared distance adds to $ds^2=dr^2+r^2\\sin^2\\alpha\\,d\\phi^2$. The change of variable $\\psi=\\phi\\sin\\alpha$ turns this into the polar metric of a plane. Cutting the cone along a generator and flattening it produces a sector of opening angle $2\\pi\\sin\\alpha$.\n",
    "\n",
    "Without a tangential force a particle follows a straight line in the unrolled sector. Its coordinates need not evolve linearly in the original azimuth. For two positions at equal slant distance $R$ separated by physical azimuth $\\Delta\\phi$ of magnitude at most $\\pi$, the shortest branch uses a straight chord spanning $\\Delta\\psi=\\sin\\alpha\\,\\Delta\\phi$. Bisecting the isosceles triangle gives\n",
    "\n",
    "$$L=2R\\sin(|\\Delta\\psi|/2),\\qquad r_{\\min}=R\\cos(\\Delta\\psi/2).$$\n",
    "\n",
    "The other copies of the endpoint correspond to winding around the cone on different branches. The chord formula uses a branch reached without passing through the apex. When the physical endpoints are diametrically opposite, clockwise and anticlockwise branches have equal shortest length. A laboratory string stretched across the interior would use the three-dimensional chord, which need not stay on the surface."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5228403a2014",
   "metadata": {
    "fundamentals": {
     "section": "worked-prediction"
    }
   },
   "source": [
    "## Detect the departure from the horizontal ring\n",
    "\n",
    "For a cone of half-angle 30 degrees, two marks 120 degrees apart at slant distance 5 cm appear only 60 degrees apart in the plane. Their shortest surface path is 5.00 cm long and passes through radius 4.33 cm. Staying on the horizontal ring would require $R\\Delta\\psi=5.24$ cm. The straight three-dimensional chord between the same marks is only 4.33 cm long but cuts through the cone. Comparing those three lengths distinguishes a free-space displacement from two distinct constrained motions."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4be12e205ef4",
   "metadata": {
    "fundamentals": {
     "section": "choose-inputs",
     "notebook_only": true
    }
   },
   "source": [
    "## Set the experimental inputs\n",
    "\n",
    "Edit these values, then run the calculation and both figures again."
   ]
  },
  {
   "cell_type": "code",
   "id": "a747a893b677",
   "metadata": {},
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "teal, orange, blue = \"#19596a\", \"#aa462a\", \"#3868a0\"\n",
    "def axes(xlabel, ylabel):\n",
    "    fig, ax = plt.subplots(figsize=(7, 4), constrained_layout=True)\n",
    "    ax.set(xlabel=xlabel, ylabel=ylabel)\n",
    "    ax.grid(alpha=0.2)\n",
    "    return fig, ax"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "id": "5387571e845d",
   "metadata": {},
   "source": [
    "half_angle_deg = 30.\n",
    "azimuth_deg = 120.\n",
    "slant_cm = 5."
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "id": "b6f02c374f30",
   "metadata": {},
   "source": [
    "assert 0 < half_angle_deg < 90 and 0 < azimuth_deg <= 180 and slant_cm > 0\n",
    "s = np.sin(np.deg2rad(half_angle_deg))\n",
    "delta = np.deg2rad(azimuth_deg)*s\n",
    "edge = delta/2\n",
    "closest = slant_cm*np.cos(edge)\n",
    "length = 2*slant_cm*np.sin(edge)\n",
    "assert length <= slant_cm*delta + 1e-12\n",
    "print(f\"Surface chord {length:.3f} cm, ring arc {slant_cm*delta:.3f} cm, closest radius {closest:.3f} cm\")"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "id": "83406a6d3182",
   "metadata": {
    "fundamentals": {
     "figure": {
      "file": "classical-mechanics-analytical-mechanics-1.png",
      "alt": "An arc between marked points on an unrolled cone is longer than the straight interior chord.",
      "caption": "The endpoints share a radius while the middle of the geodesic lies closer to the apex. Both axes measure lengths intrinsic to the surface."
     }
    }
   },
   "source": [
    "angles = np.linspace(-edge,edge,160)\n",
    "fig, ax = axes(\"Unrolled radial-axis projection (cm)\", \"Unrolled transverse coordinate (cm)\")\n",
    "for end in [-edge,edge]:\n",
    "    ax.plot([0,slant_cm*np.cos(end)],[0,slant_cm*np.sin(end)],color=\"#90999c\",lw=1)\n",
    "ax.plot(slant_cm*np.cos(angles),slant_cm*np.sin(angles),color=orange,label=\"Constant slant radius\")\n",
    "ax.plot([closest,closest],[-length/2,length/2],color=teal,lw=2.5,label=\"Shortest surface path\")\n",
    "ax.scatter([0],[0],color=blue,label=\"Apex\");ax.set_aspect(\"equal\",adjustable=\"box\");ax.legend()\n",
    "plt.show()"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "markdown",
   "id": "16acb74a476e",
   "metadata": {
    "fundamentals": {
     "notebook_only": true
    }
   },
   "source": [
    "The endpoints share a radius while the middle of the geodesic lies closer to the apex. Both axes measure lengths intrinsic to the surface."
   ]
  },
  {
   "cell_type": "code",
   "id": "e7f2f295c5f4",
   "metadata": {
    "fundamentals": {
     "figure": {
      "file": "classical-mechanics-analytical-mechanics-2.png",
      "alt": "Minimum slant distance and path length vary differently with azimuthal separation.",
      "caption": "Changing only the endpoint separation alters the sag towards the apex. At small separation the geodesic length approaches the circular arc."
     }
    }
   },
   "source": [
    "sweep=np.linspace(0,180,181); phi=np.deg2rad(sweep)*s\n",
    "fig, ax=axes(\"Physical separation (degrees of azimuth)\", \"Surface length (cm)\")\n",
    "ax.plot(sweep,2*slant_cm*np.sin(phi/2),color=teal,label=\"Geodesic length\")\n",
    "ax.plot(sweep,slant_cm*phi,\"--\",color=orange,label=\"Ring arc length\")\n",
    "ax.plot(sweep,slant_cm*np.cos(phi/2),color=blue,label=\"Closest slant radius\")\n",
    "ax.axvline(azimuth_deg,color=\"grey\",ls=\":\");ax.legend()\n",
    "plt.show()"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "markdown",
   "id": "16b13fa3de8b",
   "metadata": {
    "fundamentals": {
     "notebook_only": true
    }
   },
   "source": [
    "Changing only the endpoint separation alters the sag towards the apex. At small separation the geodesic length approaches the circular arc."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c023b2c5f678",
   "metadata": {
    "fundamentals": {
     "section": "problem-1"
    }
   },
   "source": [
    "## Exercise · infer the slope\n",
    "\n",
    "Two marks at slant distance 10 cm and azimuth separation 120 degrees have a geodesic of length 10 cm. What is the cone half-angle?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d695a9fd7dc",
   "metadata": {
    "fundamentals": {
     "solution": true
    }
   },
   "source": [
    "The measured chord gives\n",
    "\n",
    "$$\n",
    "\\sin(\\Delta\\psi/2)=10/(2\\cdot10)=1/2.\n",
    "$$\n",
    "\n",
    "The shortest branch has $\\Delta\\psi=60^\\circ$, hence $\\sin\\alpha=60/120=1/2$ and $\\alpha=30^\\circ$. Use the same angular units in the ratio."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c155b4a93b31",
   "metadata": {
    "fundamentals": {
     "section": "problem-2"
    }
   },
   "source": [
    "## Exercise · compare with a weakly curved path\n",
    "\n",
    "Find the relative excess of ring length over geodesic for a small unrolled separation $\\delta$. Why does a very small patch look flat?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "289a54d5f8ac",
   "metadata": {
    "fundamentals": {
     "solution": true
    }
   },
   "source": [
    "Expanding $2\\sin(\\delta/2)=\\delta-\\delta^3/24+\\cdots$ gives\n",
    "\n",
    "$$\n",
    "(R\\delta-L)/(R\\delta)=\\delta^2/24+O(\\delta^4).\n",
    "$$\n",
    "\n",
    "Both paths have the same tangent at leading order. The cone away from its apex is intrinsically developable; the small difference here measures the curvature of the chosen ring inside that developed plane."
   ]
  }
 ]
}
