Skip to content

Weapon

A base class for creating Weapon.

Attributes:

Name Type Description
sight_height Distance

Sight height

twist Distance

Twist

zero_elevation Angular

Zero elevation

sight Optional[Sight]

Sight properties

Parameters:

Name Type Description Default
sight_height Optional[Union[float, Distance]]

Vertical distance from center of bore line to center of sight line.

None
twist Optional[Union[float, Distance]]

Distance for barrel rifling to complete one complete turn. Positive value => right-hand twist, negative value => left-hand twist.

None
zero_elevation Optional[Union[float, Angular]]

Angle of barrel relative to sight line when sight is set to "zero." (Typically computed by ballistic Calculator.)

None
sight Optional[Sight]

Sight properties

None
Example

This is how you can create a weapon

from py_ballisticcalc import Weapon, Unis, Sight

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)
    )
)
Source code in py_ballisticcalc\munition.py
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
def __init__(self,
             sight_height: Optional[Union[float, Distance]] = None,
             twist: Optional[Union[float, Distance]] = None,
             zero_elevation: Optional[Union[float, Angular]] = None,
             sight: Optional[Sight] = None):
    """
    Create a new weapon instance with given parameters

    Args:
        sight_height: Vertical distance from center of bore line to center of sight line.
        twist: Distance for barrel rifling to complete one complete turn.
            Positive value => right-hand twist, negative value => left-hand twist.
        zero_elevation: Angle of barrel relative to sight line when sight is set to "zero."
            (Typically computed by ballistic Calculator.)
        sight: Sight properties

    Example:
        This is how you can create a weapon

        ```python
        from py_ballisticcalc import Weapon, Unis, Sight

        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)
            )
        )
        ```
    """
    self.sight_height = PreferredUnits.sight_height(sight_height or 0)
    self.twist = PreferredUnits.twist(twist or 0)
    self.zero_elevation = PreferredUnits.angular(zero_elevation or 0)
    self.sight = sight

sight_height instance-attribute

sight_height: Distance = sight_height(sight_height or 0)

twist instance-attribute

twist: Distance = twist(twist or 0)

zero_elevation instance-attribute

zero_elevation: Angular = angular(zero_elevation or 0)

sight instance-attribute

sight: Optional[Sight] = sight