Skip to content

πŸ”« Weapon

API Documentation

py_ballisticcalc.munition.Weapon

A Weapon instance is a mutable object that describes all details of a gun that can affect a trajectory.

Weapon propertiesΒΆ

  • sight_height: Sight height, which is the distance between the line of sight and barrel center at the muzzle, measured perpendicular to the line of sight as shown in the following figure:How to measure sight height

  • sight: Sight details for converting adjustments into click values.

  • twist: Twist rate of barrel rifling, in terms of length to complete 1 rotation. Positive values indicate right-hand twist, negative values indicate left-hand twist.

  • zero_elevation: Angle of barrel centerline relative to line of sight when the sight is set to "zero."

ExampleΒΆ

Imports:

from py_ballisticcalc import Weapon, Unit, Sight

Then create a Weapon instance:

weapon = Weapon(
    sight_height=Unit.Inch(2.),
    twist=Unit.Inch(10.),
    zero_elevation=Unit.Mil(0),
    sight=Sight(
        'FFP', 2,
        h_click_size=Unit.Mil(0.2),
        v_click_size=Unit.Mil(0.2)
    )
)
In this example, we use calls to Unit to initialize Weapon fields with specific unit types. We also can do it using float values, in which case those attributes will be initialized with unit types defined by PreferredUnits class.