{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Initial Launch Positions\n", "\n", "This short notebook demonstrates how to inspect a trebuchet's starting configuration and visualize it.\n", "\n", "- Create a default `HingedCounterweightTrebuchet`\n", "- Print the initial angles in degrees for the arm, counterweight, and projectile\n", "- Render a clean plot of the initial position\n", "\n", "Tip: You can tweak geometric parameters on `HingedCounterweightTrebuchet.default()` and re-run to see how the initial pose changes." ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "from math import pi\n", "\n", "from pytrebuchet.plotting.initial_position import plot_initial_position\n", "from pytrebuchet.trebuchet import HingedCounterweightTrebuchet" ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "## 1. Setup\n", "\n", "We import the core classes and a helper plotting function. The default factory `HingedCounterweightTrebuchet.default()` supplies a reasonable geometry and masses." ] }, { "cell_type": "markdown", "id": "3", "metadata": {}, "source": [ "## 2. Inspect initial angles\n", "\n", "We print the initial angles in degrees for:\n", "\n", "- Arm (main beam)\n", "- Counterweight\n", "- Projectile (at sling end)" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "trebuchet = (\n", " HingedCounterweightTrebuchet.default()\n", ") # Create a default hinged counterweight trebuchet\n", "\n", "print(f\"Initial angle arm: {trebuchet.init_angle_arm * 180 / pi:.2f} deg\")\n", "print(f\"Initial angle weight: {trebuchet.init_angle_weight * 180 / pi:.2f} deg\")\n", "print(f\"Initial angle projectile: {trebuchet.init_angle_projectile * 180 / pi:.2f} deg\")" ] }, { "cell_type": "markdown", "id": "5", "metadata": {}, "source": [ "## 3. Plot initial position\n", "\n", "We now draw the starting configuration. This helps verify the pivot height, arm lengths, sling geometry, and projectile placement before running any dynamic simulation." ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "plot_initial_position(trebuchet=trebuchet)" ] }, { "cell_type": "markdown", "id": "7", "metadata": {}, "source": [ "## 4. Whipper configuration\n", "\n", "We now do the same for a `WhipperTrebuchet`." ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "from pytrebuchet.trebuchet import WhipperTrebuchet\n", "\n", "whipper = WhipperTrebuchet.default() # Create a default whipper trebuchet\n", "\n", "print(f\"Initial angle arm: {whipper.init_angle_arm * 180 / pi:.2f} deg\")\n", "print(f\"Initial angle weight: {whipper.init_angle_weight * 180 / pi:.2f} deg\")\n", "print(f\"Initial angle projectile: {whipper.init_angle_projectile * 180 / pi:.2f} deg\")\n", "\n", "plot_initial_position(trebuchet=whipper)" ] } ], "metadata": { "kernelspec": { "display_name": ".venv (3.13.9)", "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.13.9" } }, "nbformat": 4, "nbformat_minor": 5 }