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 Distribution

ballistics_engine-0.23.0.tar.gz (33.9 kB view details)

Uploaded Source

Built Distributions

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

ballistics_engine-0.23.0-cp38-abi3-win_amd64.whl (557.1 kB view details)

Uploaded CPython 3.8+Windows x86-64

ballistics_engine-0.23.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (646.7 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

ballistics_engine-0.23.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (626.6 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

ballistics_engine-0.23.0-cp38-abi3-macosx_11_0_arm64.whl (601.5 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

ballistics_engine-0.23.0-cp38-abi3-macosx_10_12_x86_64.whl (628.9 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file ballistics_engine-0.23.0.tar.gz.

File metadata

  • Download URL: ballistics_engine-0.23.0.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for ballistics_engine-0.23.0.tar.gz
Algorithm Hash digest
SHA256 f7693b943ec125d168c934c591ae4cc37d3819188d9dca7d2087889c1d33acee
MD5 d3ae88828c89e75ae6d0ff88b99d1ef8
BLAKE2b-256 60315d749335aab10b4f33643527536d992c9bddb757b772e1f9c59933072d7c

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.23.0-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.23.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b0577c3c99adb31a9e29cf6bbff8906b10b97e2211a1825373444efb4ea042a1
MD5 27dc5b8caac3fafd0aa0e925c1b036bd
BLAKE2b-256 67f43537064d544fac8bdac26ff6df1a09a164291a7b72b18892e9c6441f7e96

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.23.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.23.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24803a59452d453bda374e4060b54a1a1fd60b7207d540bd06af261707825250
MD5 8e445fae2bedaf4a137922e97ee4eadc
BLAKE2b-256 e69e6e8b15f68a1df611e0f92bbd68227882c9badb55ae1e84a5410f3d414a28

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.23.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.23.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a23f704e2181f29237a0f8a1b734c5040efda18f5dc56508421e2c6e129b743a
MD5 e671c8817b0ad7e512d87164adbecdef
BLAKE2b-256 a1d5909126c33c26db60101f50c6bc954803572adb0b1c81bbaec44230c73403

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.23.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.23.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 85e3f4b848c1954c989461a1a775532281e2639303aac2d1da47006e8b248f74
MD5 a61ae1f5f6a42023960c533a059aef81
BLAKE2b-256 fe70470c3f2a7e9e8dd39cc41a3cb7840bb39f53cf5828236b3bf3d83ea60b7d

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.23.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.23.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1348fb2deee76a7cecdde1cc8365273e2066f061a3b666191e09ff4ebc349514
MD5 0831f4c6a76c4dfac5ed3b4d4a63144d
BLAKE2b-256 7871d047a1660f8ddd4fa605774e394d74bd095a7ce450228ce741865a457706

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