Interface
Calculator
dataclass
¶
Calculator(
config: Optional[ConfigT] = None,
engine: EngineProtocolEntry = DEFAULT_ENTRY,
)
Bases: Generic[ConfigT]
Basic interface for the ballistics calculator.
Methods:
Name | Description |
---|---|
barrel_elevation_for_target |
Calculate barrel elevation to hit target at zero_distance. |
set_weapon_zero |
Set shot.weapon.zero_elevation so that it hits a target at zero_distance. |
fire |
Calculate the trajectory for the given shot parameters. |
iter_engines |
Iterate all available engines in the entry points. |
Functions¶
barrel_elevation_for_target
¶
Calculate barrel elevation to hit target at zero_distance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shot
|
Shot
|
Shot instance we want to zero. |
required |
target_distance
|
Union[float, Distance]
|
Look-distance to "zero," which is point we want to hit. This is the distance that a rangefinder would return with no ballistic adjustment. |
required |
Note
Some rangefinders offer an adjusted distance based on inclinometer measurement. However, without a complete ballistic model these can only approximate the effects on ballistic trajectory of shooting uphill or downhill. Therefore: For maximum accuracy, use the raw sight distance and look_angle as inputs here.
Source code in py_ballisticcalc/interface.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
set_weapon_zero
¶
Set shot.weapon.zero_elevation so that it hits a target at zero_distance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shot
|
Shot
|
Shot instance to zero. |
required |
zero_distance
|
Union[float, Distance]
|
Look-distance to "zero," which is point we want to hit. |
required |
Source code in py_ballisticcalc/interface.py
175 176 177 178 179 180 181 182 183 |
|
fire
¶
fire(
shot: Shot,
trajectory_range: Union[float, Distance],
trajectory_step: Optional[
Union[float, Distance]
] = None,
*,
extra_data: bool = False,
dense_output: bool = False,
time_step: float = 0.0,
flags: Union[TrajFlag, int] = NONE,
raise_range_error: bool = True,
) -> HitResult
Calculate the trajectory for the given shot parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shot
|
Shot
|
Shot parameters, including position and barrel angle. |
required |
trajectory_range
|
Union[float, Distance]
|
Distance at which to stop computing the trajectory. |
required |
trajectory_step
|
Optional[Union[float, Distance]]
|
Distance between recorded trajectory points. Defaults to |
None
|
extra_data
|
bool
|
[DEPRECATED] Requests flags=TrajFlags.ALL and trajectory_step=PreferredUnits.distance(1). |
False
|
dense_output
|
bool
|
HitResult stores all calculation steps so it can interpolate any point. |
False
|
time_step
|
float
|
Maximum time between recorded points. If > 0, points are recorded at least this frequently. Defaults to 0.0. |
0.0
|
flags
|
Union[TrajFlag, int]
|
Flags for specific points of interest. Defaults to TrajFlag.NONE. |
NONE
|
raise_range_error
|
bool
|
If True, raises RangeError if returned by integration. |
True
|
Returns:
Name | Type | Description |
---|---|---|
HitResult |
HitResult
|
Object containing computed trajectory. |
Source code in py_ballisticcalc/interface.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
iter_engines
staticmethod
¶
iter_engines() -> Generator[EntryPoint, None, None]
Iterate all available engines in the entry points.
Source code in py_ballisticcalc/interface.py
232 233 234 235 |
|