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.21.4.tar.gz (34.3 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.21.4-cp38-abi3-win_amd64.whl (539.1 kB view details)

Uploaded CPython 3.8+Windows x86-64

ballistics_engine-0.21.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (637.2 kB view details)

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

ballistics_engine-0.21.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (620.9 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

ballistics_engine-0.21.4-cp38-abi3-macosx_11_0_arm64.whl (582.6 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

ballistics_engine-0.21.4-cp38-abi3-macosx_10_12_x86_64.whl (605.1 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for ballistics_engine-0.21.4.tar.gz
Algorithm Hash digest
SHA256 4203bf98f98ea8b486fd597f2caec00f516d0ac459f69d7889dd76d655ac5a60
MD5 fb7d9bdd76aa796be0bba66f1eb83fee
BLAKE2b-256 a1ef295412c26149b8b75ee3485152f646e155f2605fe83a8e5e4f7ecb15b327

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.21.4-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 90cc548e041aacb38dcbdfc23b4428281249b19037006399c0addf6511abb947
MD5 6751cea7fb5daa91a8ecb22a51b66d77
BLAKE2b-256 f30e4acdfaba5ab0e05855bcf9ef6bb77956e52c1e5837dd1fbe8952d008cc78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.21.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 994618b5cac4c65f6a726385359f0c5e916f13e4d54aebb793d953a82fc41c29
MD5 c0681ac7439a6892b4cc48450670de49
BLAKE2b-256 b8e86acfa52fa15dec9375c485b1da5afc6a7ce036d3c50288c26e604deb17b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.21.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fdc797963a10402d26e8db028b1e65c6d2ba9412dbd441b35e2d3824c486993b
MD5 fc67cd7fb88e01a3182b6402b17a71e2
BLAKE2b-256 450fa80aacc998841bd0d205f16affc8cd63258200c9dc07523ed556ff7dcdfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.21.4-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8919f3fbe585cfdb5282cd9875278829b0c85c5478c38ae9038d137cc96444d1
MD5 2c6a44cf7aeee6d4db3279d30e9fe112
BLAKE2b-256 caabf0e0fecf89e379e8b0bc8516597f788535adaf43103ff92778fefe906140

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.21.4-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 86e05e6aec81781b7b3bcabf8bf2382f41733061492b2cfd6e4818e118128c14
MD5 4fdbcbb8451f5d9f1def3d8af462fe06
BLAKE2b-256 0fa04ed29216ec071b1b6ddd9ff8516ad398669799cf6eb53e2dcb4cffe355e3

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