{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Projectile Motion Equations\n", "\n", "This notebook derives the equations for the projectile's position, velocity and acceleration as a function of the trebuchet's angle parameters" ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "from sympy import Function, cos, diff, simplify, sin, symbols\n", "\n", "# Define the trebuchet angle variables (time-dependent)\n", "t = symbols(\"t\")\n", "theta = Function(\"theta\")(t) # Arm angle\n", "psi = Function(\"psi\")(t) # Sling angle\n", "\n", "# Define the trebuchet lengths\n", "l2, l3 = symbols(\"l2 l3\") # Length of arm and sling\n", "\n", "# Define the position of the projectile\n", "px = -l2 * cos(theta) + l3 * cos(psi)\n", "py = -l2 * sin(theta) + l3 * sin(psi)\n", "\n", "# Derive the velocity components by differentiating position with respect to time\n", "vx = simplify(diff(px, t))\n", "vy = simplify(diff(py, t))\n", "\n", "# Derive the acceleration components by differentiating velocity with respect to time\n", "ax = simplify(diff(vx, t))\n", "ay = simplify(diff(vy, t))\n", "\n", "# Output the results\n", "print(\"Projectile Position:\")\n", "print(f\"px: {px}\")\n", "print(f\"py: {py}\\n\")\n", "print(\"Projectile Velocity:\")\n", "print(f\"vx: {vx}\")\n", "print(f\"vy: {vy}\\n\")\n", "print(\"Projectile Acceleration:\")\n", "print(f\"ax: {ax}\")\n", "print(f\"ay: {ay}\")" ] } ], "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 }