Skip to main content

High-performance ballistics trajectory engine with professional physics

Project description

ballistics-engine

High-performance ballistics trajectory engine with professional physics modeling.

Features

  • Professional-grade trajectory calculations with multiple drag models (G1, G7, G8)
  • Advanced physics including wind effects and atmospheric modeling
  • Fast Rust implementation with Python bindings via PyO3
  • Imperial units API (grains, fps, yards, inches) with automatic metric conversion

Installation

pip install ballistics-engine

Quick Start

from ballistics_engine import BallisticInputs, TrajectorySolver, WindConditions, AtmosphericConditions, DragModel

# Create ballistic inputs (all imperial units)
inputs = BallisticInputs(
    bc=0.505,                        # G7 BC
    bullet_weight_grains=168,        # grains
    muzzle_velocity_fps=2650,        # feet per second
    bullet_diameter_inches=0.308,    # inches
    bullet_length_inches=1.24,       # inches
    sight_height_inches=1.5,         # inches above bore
    zero_distance_yards=100,         # yards
    twist_rate_inches=11.25,         # inches per turn
)
inputs.drag_model = DragModel.g7()  # Use G7 drag model

# Create wind conditions (optional)
wind = WindConditions(
    speed_mph=10,                    # mph
    direction_degrees=90,            # degrees (0=headwind, 90=from right)
)

# Create atmospheric conditions (optional)
atmosphere = AtmosphericConditions(
    temperature_f=59,                # Fahrenheit
    pressure_inhg=29.92,             # inHg
    humidity_percent=50,             # percent
    altitude_feet=0,                 # feet
)

# Solve trajectory
solver = TrajectorySolver(inputs, wind=wind, atmosphere=atmosphere)
result = solver.solve()

# Print results
print(f"Max range: {result.max_range_yards:.1f} yards")
print(f"Time of flight: {result.time_of_flight:.2f} seconds")
print(f"Impact velocity: {result.impact_velocity_fps:.1f} fps")
print(f"Impact energy: {result.impact_energy_ftlbs:.1f} ft-lbs")

# Iterate through trajectory points
for point in result.points:
    print(f"Time: {point.time:.2f}s, X: {point.x:.1f}yd, Y: {point.y:.3f}yd, V: {point.velocity_fps:.1f}fps")

Units

The Python API uses imperial units for convenience:

  • Mass: grains (gr)
  • Velocity: feet per second (fps)
  • Distance: yards (yd) and inches (in)
  • Pressure: inches of mercury (inHg)
  • Temperature: Fahrenheit (°F)
  • Wind speed: miles per hour (mph)

All conversions to metric (used internally by the Rust engine) are handled automatically.

API Reference

BallisticInputs

Main input parameters for trajectory calculation.

Parameters:

  • bc (float): Ballistic coefficient
  • bullet_weight_grains (float): Bullet mass in grains
  • muzzle_velocity_fps (float): Muzzle velocity in fps
  • bullet_diameter_inches (float): Bullet diameter in inches
  • bullet_length_inches (float): Bullet length in inches
  • sight_height_inches (float): Sight height above bore in inches
  • zero_distance_yards (float): Zero distance in yards
  • shooting_angle_degrees (float): Uphill/downhill angle in degrees
  • twist_rate_inches (float): Barrel twist rate (inches per turn)
  • is_right_twist (bool): True for right-hand twist (default: True)

WindConditions

Wind parameters.

Parameters:

  • speed_mph (float): Wind speed in mph (default: 0)
  • direction_degrees (float): Wind direction in degrees (0=headwind, 90=from right, default: 0)

AtmosphericConditions

Atmospheric parameters.

Parameters:

  • temperature_f (float): Temperature in Fahrenheit (default: 59)
  • pressure_inhg (float): Barometric pressure in inHg (default: 29.92)
  • humidity_percent (float): Relative humidity percentage (default: 50)
  • altitude_feet (float): Altitude in feet (default: 0)

TrajectorySolver

Trajectory calculation engine.

Methods:

  • __init__(inputs, wind=None, atmosphere=None): Create solver with inputs
  • solve(): Calculate trajectory, returns TrajectoryResult

TrajectoryResult

Trajectory calculation results.

Properties:

  • max_range_yards (float): Maximum range in yards
  • max_height_yards (float): Maximum height in yards
  • time_of_flight (float): Total flight time in seconds
  • impact_velocity_fps (float): Impact velocity in fps
  • impact_energy_ftlbs (float): Impact energy in ft-lbs
  • points (list[TrajectoryPoint]): List of trajectory points

TrajectoryPoint

Individual point along trajectory.

Properties:

  • time (float): Time in seconds
  • x (float): Downrange distance in yards
  • y (float): Vertical position in yards (relative to line of sight)
  • z (float): Lateral position in yards
  • velocity_fps (float): Velocity in fps
  • energy_ftlbs (float): Kinetic energy in ft-lbs

DragModel

Drag model selection.

Static methods:

  • DragModel.g1(): G1 drag model (flat base)
  • DragModel.g7(): G7 drag model (boat tail)
  • DragModel.g8(): G8 drag model (boat tail with meplat)

License

Dual licensed under MIT or Apache-2.0.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ballistics_engine-0.13.3-cp313-cp313-manylinux_2_34_x86_64.whl (329.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.3-cp313-cp313-manylinux_2_34_aarch64.whl (328.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

ballistics_engine-0.13.3-cp312-cp312-win_amd64.whl (209.0 kB view details)

Uploaded CPython 3.12Windows x86-64

ballistics_engine-0.13.3-cp312-cp312-manylinux_2_34_x86_64.whl (332.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.3-cp312-cp312-macosx_11_0_arm64.whl (299.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ballistics_engine-0.13.3-cp312-cp312-macosx_10_12_x86_64.whl (309.8 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

ballistics_engine-0.13.3-cp311-cp311-win_amd64.whl (208.0 kB view details)

Uploaded CPython 3.11Windows x86-64

ballistics_engine-0.13.3-cp311-cp311-manylinux_2_34_x86_64.whl (331.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.3-cp311-cp311-macosx_11_0_arm64.whl (299.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ballistics_engine-0.13.3-cp311-cp311-macosx_10_12_x86_64.whl (308.8 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

ballistics_engine-0.13.3-cp310-cp310-win_amd64.whl (208.2 kB view details)

Uploaded CPython 3.10Windows x86-64

ballistics_engine-0.13.3-cp310-cp310-manylinux_2_34_x86_64.whl (331.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.3-cp310-cp310-macosx_11_0_arm64.whl (299.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ballistics_engine-0.13.3-cp310-cp310-macosx_10_12_x86_64.whl (309.1 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

ballistics_engine-0.13.3-cp39-cp39-win_amd64.whl (208.4 kB view details)

Uploaded CPython 3.9Windows x86-64

ballistics_engine-0.13.3-cp39-cp39-manylinux_2_34_x86_64.whl (331.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.3-cp39-cp39-macosx_11_0_arm64.whl (299.4 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ballistics_engine-0.13.3-cp39-cp39-macosx_10_12_x86_64.whl (309.3 kB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

ballistics_engine-0.13.3-cp38-cp38-win_amd64.whl (208.5 kB view details)

Uploaded CPython 3.8Windows x86-64

ballistics_engine-0.13.3-cp38-cp38-manylinux_2_34_x86_64.whl (331.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.3-cp38-cp38-macosx_11_0_arm64.whl (299.4 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

ballistics_engine-0.13.3-cp38-cp38-macosx_10_12_x86_64.whl (309.4 kB view details)

Uploaded CPython 3.8macOS 10.12+ x86-64

File details

Details for the file ballistics_engine-0.13.3-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 089cfce5b90e70c76684c8a8d3fd8debfba960fb46738d6ef9c7956bbe0bdb7d
MD5 8acd5646e55a4a342c44f7fde8aecf6f
BLAKE2b-256 3a5a381ce985f997013f04d3e6d1478f0e9bf2c2a6eb9e288a4fd1b815e24378

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 189c65734c18c47ff42069afb88f4044b75677f5003331f2388cc738e990f433
MD5 7cf92373f13b2931fc95cd9c3fc1f716
BLAKE2b-256 c3715bb2f22351fc726521dceb4f9182ebee8091112329255b4e2195e22b1290

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fe01dbacd5a8c20b462bbfe74968c9e6d62118a74044cf633cc08df9465e5718
MD5 1675d0a28535feedd6d48517dcd3a5aa
BLAKE2b-256 63e20a63abd56b003e6bdb5eca8ccf55529c4a57f7c4bb23741399c8be93f368

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 08f30d4fea109325014c234ad5ef1c0d57702d9b4cd4ee3bcab037c56a0e6f17
MD5 288c0fb2ee2f18b29391a4854f12c66a
BLAKE2b-256 794a5266ebd0f6783378f3a86f41aa33da18960c82abb9be4fb9ef8aa02b93a0

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c27fd0d81814828486e592005e708d83ea41dd7226377a0d8560876011632c8e
MD5 293c810e7e3d033ba4bf0ddbe38929bd
BLAKE2b-256 180a8d09faf30dbb7a12d4fab73a4ed1d300495b61856e932551232d186672e5

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a1363f6c03ebc537030859e2e552238ac0da15855f7a75590bc5ce914ca862a8
MD5 b45c289fe42e049ac20f041a1bdcfad3
BLAKE2b-256 3900293c25c4ef1f2dce72737029af22b82e1e50ca7520aea604b2bffd105ba8

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 be445c29c96d4b6870e2c6dd2bc854afd3f5fd8f5baf49f40103c1952ffe9706
MD5 56dd405be2feab866ed015117e926022
BLAKE2b-256 c2ab382c1a56eb3d088c4be96b6bc11cc97c2bec90ec4dbc6767ef9ca2e2b93b

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 799ac34b89d5119ec6b47bf8fc757cdec930a6312448fcaea70326a2def0f806
MD5 ae4e92a7956801d3df912eddb54fae22
BLAKE2b-256 4bb96c4e23bc89e55c7fc05bcefdfa614de1c754d46fd730685bf231b28b622b

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 268b0fdd64ce6b7e9377fb368a962c78d712e0118c8efeac4b3ddc6e37a3da0f
MD5 dec44fa4e599df1d289590b9b69c2253
BLAKE2b-256 59793c13a5cc350a2d7497b0d93c39b15da371dd6309d4e6177bfdb15852c563

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d1fe9855d3381bc919d9e05acec7f0465fd0b400e8d1e267c883bf0387fb5d7f
MD5 2a50526822c45af722536815599c88b1
BLAKE2b-256 c73c67474b596368b9596cb8934f4a3612fd2cf04748e91d9aae55aebcc5c85e

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 804a6ee202792816bcff674b1c60042bb7fffc751e5b9be748b30c7d060b70e0
MD5 064b17c0bae72cfba4d339659d1c0ea1
BLAKE2b-256 e9837a918a0178466a30d0f407fe85acf5bf9d6976445c2a5860ea661efb910b

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 554186fba29ce35b2c5413d45efc0d9a512d01683a7fa752b078b1bcd814e414
MD5 b0a3aae9fe0ac52d9fabe741dd465038
BLAKE2b-256 de3175a70ce82af68bb7bb6c1b66e5a2dd318a9ab2b4aa399330aca8284fe1b3

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 37fb36ced02c33c193d2f921a0d6be5b85ebfa9885168205dfe37384e1425e1a
MD5 3330df46090f94acfe79138cb160a520
BLAKE2b-256 fd7ee6c0bf8f6bcb1427b91b75caffe1ce24047fb5c6a37ecf3e54e394223b0d

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5260b07fe5ab608d9053be2701798e98f941dcdd6227044f58660dbf423bca79
MD5 6990b6b3a9839050c428c5dd1e458dea
BLAKE2b-256 1d3f7774b688d3323441acc0e8f1bbf6194e467c899cd861a464139b9d5bd240

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 719571eae43a3a872a3a7ddc65aabedf773943727256f1411886f34a490c7500
MD5 5c675bdc736a92ef9b9f476357862a72
BLAKE2b-256 dad069bfbb15b4457abd33548bb38a1e255d9b94dac13120c5faea9d933a99bb

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f42a47e742efefa6b2bade56576eba8394ba9c2a954778dd64cdbf78ffa3699f
MD5 01d311ef624a485a5842a36cb8486b13
BLAKE2b-256 0fa3363706ca0d0e993f9a0c9f27af551e4f762e518869479f0b4cadb74be59f

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0a351823e8551a5453a01d4e05c9aa522731a4542601f657d6981ad4dfa72205
MD5 8725dd3d287394b4744e5229f5413fe7
BLAKE2b-256 2e4c10e58e4e0dce092ded74fd189283609df224adeab49029585be2ee96a284

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp39-cp39-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8c69232edb59933f0a784c08fc3cd5fc0dbf2f9fa25ea26a50e679d7bdcc9032
MD5 407366a010b0d1d85b16fcd991d9e13d
BLAKE2b-256 42f12204bfbc976c88fc56f88b7def31e7938856c069fea4627603616325e7a5

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2418a70f6c28b5973582bc8eec27069c3792d853253fa309c30b0f80fa456de7
MD5 fd9edd2c74e510b5a5a29b80beb8505f
BLAKE2b-256 b21f859d740adad3db02fe0947f1335939c2801ace50349a6f97e5c194a23fe4

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 add55526c5be992ee7584b1f30144f50f26ea2e95685d48e35bb12a4338805b7
MD5 75e7d475c5f4885e07e2e322d6cba9bf
BLAKE2b-256 a06c34dd7adbf11278f64fb7c575f605011f7a13fb3e1a3365a08a5ed09dbeff

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 edf49b15d2a3ec92be1e9fbfb7573f60ed8d9463463a3b4d16655d33420f2534
MD5 93a29a9c2647f2c00aa5d086b8b8476c
BLAKE2b-256 3f9d3e2208e56ec038e71c2334e88cf9b7a4fa3023927a80077193a82cbe39b1

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.3-cp38-cp38-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.3-cp38-cp38-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b3f499d6a37b60e962629dedd9f5c40c95112ec8df8664b732857803f96c8b9c
MD5 e3977aa457da3fa9bcf708a936067199
BLAKE2b-256 4b2a85272e9129b340ff65f8d33f0caf139b1aa47ffec835a1448ab36184d37d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page