Initial Launch Positions

This short notebook demonstrates how to inspect a trebuchet’s starting configuration and visualize it.

  • Create a default HingedCounterweightTrebuchet

  • Print the initial angles in degrees for the arm, counterweight, and projectile

  • Render a clean plot of the initial position

Tip: You can tweak geometric parameters on HingedCounterweightTrebuchet.default() and re-run to see how the initial pose changes.

[1]:
from math import pi

from pytrebuchet.plotting.initial_position import plot_initial_position
from pytrebuchet.trebuchet import HingedCounterweightTrebuchet

1. Setup

We import the core classes and a helper plotting function. The default factory HingedCounterweightTrebuchet.default() supplies a reasonable geometry and masses.

2. Inspect initial angles

We print the initial angles in degrees for:

  • Arm (main beam)

  • Counterweight

  • Projectile (at sling end)

[2]:
trebuchet = (
    HingedCounterweightTrebuchet.default()
)  # Create a default hinged counterweight trebuchet

print(f"Initial angle arm: {trebuchet.init_angle_arm * 180 / pi:.2f} deg")
print(f"Initial angle weight: {trebuchet.init_angle_weight * 180 / pi:.2f} deg")
print(f"Initial angle projectile: {trebuchet.init_angle_projectile * 180 / pi:.2f} deg")
Initial angle arm: 47.41 deg
Initial angle weight: -90.00 deg
Initial angle projectile: 0.00 deg

3. Plot initial position

We now draw the starting configuration. This helps verify the pivot height, arm lengths, sling geometry, and projectile placement before running any dynamic simulation.

[3]:
plot_initial_position(trebuchet=trebuchet)
../_images/examples_plot_initial_position_6_0.png
[3]:
(<Figure size 640x480 with 1 Axes>,
 <Axes: title={'center': 'Trebuchet Initial Position'}, xlabel='X', ylabel='Y'>)

4. Whipper configuration

We now do the same for a WhipperTrebuchet.

[4]:
from pytrebuchet.trebuchet import WhipperTrebuchet

whipper = WhipperTrebuchet.default()  # Create a default whipper trebuchet

print(f"Initial angle arm: {whipper.init_angle_arm * 180 / pi:.2f} deg")
print(f"Initial angle weight: {whipper.init_angle_weight * 180 / pi:.2f} deg")
print(f"Initial angle projectile: {whipper.init_angle_projectile * 180 / pi:.2f} deg")

plot_initial_position(trebuchet=whipper)
Initial angle arm: 240.00 deg
Initial angle weight: 70.00 deg
Initial angle projectile: 238.60 deg
../_images/examples_plot_initial_position_8_1.png
[4]:
(<Figure size 640x480 with 1 Axes>,
 <Axes: title={'center': 'Trebuchet Initial Position'}, xlabel='X', ylabel='Y'>)