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.24.1.tar.gz (45.8 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.24.1-cp38-abi3-win_amd64.whl (588.9 kB view details)

Uploaded CPython 3.8+Windows x86-64

ballistics_engine-0.24.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (673.2 kB view details)

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

ballistics_engine-0.24.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (652.1 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

ballistics_engine-0.24.1-cp38-abi3-macosx_11_0_arm64.whl (628.0 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

ballistics_engine-0.24.1-cp38-abi3-macosx_10_12_x86_64.whl (659.5 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for ballistics_engine-0.24.1.tar.gz
Algorithm Hash digest
SHA256 0f7f1a18cb109cd501a296841420e8959fe5dc812b91787b776e33c374d7fe87
MD5 fe1f8521c3c271bc9635a7f85031d010
BLAKE2b-256 0b280b1cae45a92dca8fed97c09b4216bb088984b345fe74f02c45aed092ecaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.24.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f3c30364f7d0224ea0cba606aa0aaa867280f5707a934ee43bd5d3576f781a16
MD5 6edcd69b9c252a53cc16168c01f49054
BLAKE2b-256 6e653d9d0a5c5b2e5daef9444d6cccd097e14880fe9739945458323f3c4b810b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.24.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e158df53db85b02a56a665300fd2232ccfac3612a741f8709bfcb99b2c628b4
MD5 f49e6a285249ee4a0c7ffae9acb16e95
BLAKE2b-256 5927cf148ee63b51d69515158699139abd63d244079fe8d28810f7cacdd34abb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.24.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0685b040f61090a730abf5d4fccd3659c4494ef0d32339183d7e781d46b972fa
MD5 882f384944fcad83f712341715c35e0d
BLAKE2b-256 b3794eab7144846f88f4cf8176394dffce30b97dafd1aa8254d5174f5c67d000

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.24.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b41620d7fdd130be0994dd5414e69f1be489d73d46ef075ae3d0adb466fa6a9
MD5 b7eb5e138442d44199cf57e2f71ce6a5
BLAKE2b-256 5aefd21a246219344e4f943548e4c0804e22b0199d6914359bde441a00c70492

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.24.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3ee7dc60b69d6ef2f641cbbdbbac88f8c680bc0725c8f569e88872ebfa4467b1
MD5 ea32ee852fc61792751b66bac157ade9
BLAKE2b-256 e74be812695099b646a6fd4a6c8bfd7d467495593c035589b485f7f6dedeaeb0

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