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.4-cp312-cp312-win_amd64.whl (208.5 kB view details)

Uploaded CPython 3.12Windows x86-64

ballistics_engine-0.13.4-cp312-cp312-manylinux_2_34_x86_64.whl (331.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.4-cp312-cp312-macosx_11_0_arm64.whl (299.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ballistics_engine-0.13.4-cp312-cp312-macosx_10_12_x86_64.whl (309.4 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

ballistics_engine-0.13.4-cp311-cp311-win_amd64.whl (207.5 kB view details)

Uploaded CPython 3.11Windows x86-64

ballistics_engine-0.13.4-cp311-cp311-manylinux_2_34_x86_64.whl (330.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.4-cp311-cp311-macosx_11_0_arm64.whl (298.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ballistics_engine-0.13.4-cp311-cp311-macosx_10_12_x86_64.whl (308.5 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

ballistics_engine-0.13.4-cp310-cp310-win_amd64.whl (207.6 kB view details)

Uploaded CPython 3.10Windows x86-64

ballistics_engine-0.13.4-cp310-cp310-manylinux_2_34_x86_64.whl (330.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.4-cp310-cp310-macosx_11_0_arm64.whl (298.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ballistics_engine-0.13.4-cp310-cp310-macosx_10_12_x86_64.whl (308.7 kB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

ballistics_engine-0.13.4-cp39-cp39-win_amd64.whl (207.9 kB view details)

Uploaded CPython 3.9Windows x86-64

ballistics_engine-0.13.4-cp39-cp39-manylinux_2_34_x86_64.whl (331.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.4-cp39-cp39-macosx_11_0_arm64.whl (298.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ballistics_engine-0.13.4-cp39-cp39-macosx_10_12_x86_64.whl (309.0 kB view details)

Uploaded CPython 3.9macOS 10.12+ x86-64

ballistics_engine-0.13.4-cp38-cp38-win_amd64.whl (207.9 kB view details)

Uploaded CPython 3.8Windows x86-64

ballistics_engine-0.13.4-cp38-cp38-manylinux_2_34_x86_64.whl (331.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

ballistics_engine-0.13.4-cp38-cp38-macosx_11_0_arm64.whl (299.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

ballistics_engine-0.13.4-cp38-cp38-macosx_10_12_x86_64.whl (309.0 kB view details)

Uploaded CPython 3.8macOS 10.12+ x86-64

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9d14e8a6ae7e5f8ba5a16c329744685027b30afa2c0aa033f4b2a2a405ecdbf8
MD5 f0480cec65a7564861784c898d086cfb
BLAKE2b-256 f8f3f26780d24ec9c9c1bbc17aaff248895c96567f50aa7940af24329c21d967

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c47c30796ac778dba0181b44b25560a2726aa87e8f1c114f873799e25954f16d
MD5 e5136585c513c7165e56fe53a65fb2af
BLAKE2b-256 65a1e8d2c0a5162210e737ab519e26c61f7d868b32346540af84c0d626c63527

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6bbca9a6f9010b253c55f77aafa26d74d47a936a980123deea5ed0d4b2fa5ddf
MD5 446e61a8fe434789628588bef7b32ad7
BLAKE2b-256 0f90c56f8d6936169bee1306881f007b63b6730e6a5e7678c3f79e1020fd9933

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6c496b5b29b2d9638896a24cfdbb89ab314598bbddc70baebf5e35c196ece23a
MD5 e97147db93f63b1688bbc2bb94d5744f
BLAKE2b-256 26c6639c90a790bae0620c9decf98881f4905dd1dfaacd4f391963cb3ce4270c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 02b61e43fc31a5baa9c0da64aa7e1ca2fce59cd716df73e51fa93f68d182c53c
MD5 45a6e4e8987aa50a8beb8381e080d5e7
BLAKE2b-256 c8f70a5389aadfb0add1b28796de9ac323d8d3de6b7fb8424bed6b53d9ef61d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d984fc3fe6e4c99e9b13dbf11c12c69b867b8850df9766fb83494e7b90bd6e57
MD5 3fdf6d7d54d4aa92050787c7f5480483
BLAKE2b-256 38141d8660168d17e614c50a72b53f25e98b2e6a05b32e75eb8e834795e0f687

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d97ae81218cea9ac741acd45d192fb61b79fdcd97b9b71613d3e15f4d82c106
MD5 a9185a02553c374463ed5fe1608cfb3b
BLAKE2b-256 e6ec0da77bc4d194ccb40be6756598868a6aab3ee7003618f672677af2d02859

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 42b1a6350a5ded1f6470f0b1fe0432eec9bb1388c964a7781d7655c5a1b12859
MD5 77c6d5f1b53f095fc4f8b204a9de08b3
BLAKE2b-256 1881a1e171ef49b94db553367a5dd232552547a0cca57cecc266797bc08b6a56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 31c61ce58a6bb9868b71d32a37354ed3d96313afea5e3b83cbf772ce6460f4a8
MD5 ac72a86ea378e8e92fd495743ac4d21b
BLAKE2b-256 06835694621bc91ff2ddbe2f073b4a35be24993dbd642a5699cee7c318370691

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 db090de85f78204fcd11ca9dbc5ed2ff368e07d01e9d2912ce8aecd3106cde20
MD5 0142cbf36f6541e67256f6b83ddd0e06
BLAKE2b-256 9f04ff4f83fb86fb33aa874bbb4187bccd4dbb065628dac7941c04cdcc974dcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08818523a7b71916b6a8a8e6ffec10553f70a7f9929b96ee985ad1e312446343
MD5 ee6c327aaeebbace0a5798914381b65a
BLAKE2b-256 287c66e87ae87e66168c2c365648174156005ef18e338985e2c27222b40b57a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2271ef74c6054cfa212440eb706103b743f91cf6660cab9622abccd85c0043d4
MD5 f03e225e7fd1e80fd066d7f10757dc9b
BLAKE2b-256 a873690bf1530ce84899181b3ddb102593aee47d5497f461125b2bcd339e23ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e5d94ee3b6c9b323d3350949464d29eaa472618a66788b9c8546821b14ea2364
MD5 5aa4ed3e1df15cac39c6345029ba71b5
BLAKE2b-256 62efdeff567dbfb888469fed5c17a76e857c160e0567ff60124b2ea966bcb670

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3aab570f076ee61d1a49ffcec9088ce82dbaec8eee8e48cb1249266f4d7c82cc
MD5 bdd038fc72e47cf780152542368b7eec
BLAKE2b-256 1a8bd8ff36695df8991227b36f08b992e935605443b2eac2eabae05160475d8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c449a1ece5edfa8e0d6192385ebf53716f04ea7cead6e98bcd104dc02d93bd82
MD5 133f05a3fdbdd1b86f79e548544ab4da
BLAKE2b-256 1d49cdfe06b3964bd0e68e6f5f382d76f38a20c9077d2d6412b95c7899152870

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp39-cp39-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1c203ac8f0e00bf49e483722fc94bd6b9b82cb77750f9015172ed2ef23e0e69f
MD5 daf08cf5141f0b3e099a3651516223bb
BLAKE2b-256 ec5ca0d93b5f55585887d8d09c106ce072619c60f545964a7500298ae2a5be70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 77379fa1f764d6327b1fa25e7eb999e3372da1a2c217988634861a87c35cd01f
MD5 1cf584d7248622a6fca55f832eaa9d92
BLAKE2b-256 f6fb7f80d695390e32ea020fa0a278b6607a770873785e464812302f5ec78a5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 514ff4f0de343a72f12c0895d4d24f6aa0b057aef75d2f189090e15e9d12a52d
MD5 02248a7b28d69ea8b792e805cb306360
BLAKE2b-256 672aef4b32b0257ea93606d85b62cc68c71dfc9293d5b5516fab38c964692935

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56ebd3355c499035a96ccf2515c3319a382f363313f8f02cbe2142872bb35dbf
MD5 d3e2bb81f9b3e58f012134cc92195c51
BLAKE2b-256 74a8df137c5295d28464a7927cbd73980c29b5ac0ba0a216f4780226b03cc6ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.4-cp38-cp38-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fd6ca9679d6d14dac6faefffbb2e0b8de7eca6d046ef9da1e72a3e1039c7d3ed
MD5 459c4564277d85abbf4ae0e4133a599c
BLAKE2b-256 89143ce380abf07f5eca7e01978fcf8ef2dd7dcca12fffdef5e5faf213c66f94

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