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.13.10.tar.gz (20.7 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.13.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (452.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

ballistics_engine-0.13.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (443.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

ballistics_engine-0.13.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (452.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ballistics_engine-0.13.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (443.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

ballistics_engine-0.13.10-cp311-cp311-win_amd64.whl (353.5 kB view details)

Uploaded CPython 3.11Windows x86-64

ballistics_engine-0.13.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (451.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ballistics_engine-0.13.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (443.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

ballistics_engine-0.13.10-cp311-cp311-macosx_11_0_arm64.whl (415.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ballistics_engine-0.13.10-cp311-cp311-macosx_10_12_x86_64.whl (427.9 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

ballistics_engine-0.13.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (451.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ballistics_engine-0.13.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (443.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

ballistics_engine-0.13.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (452.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

ballistics_engine-0.13.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (444.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

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

File hashes

Hashes for ballistics_engine-0.13.10.tar.gz
Algorithm Hash digest
SHA256 843aa8001bd0b8bb4238d37eca3088c6006199118862b75c6fb7970f0b2ed608
MD5 dc21d118a10e598dea731f2319501a58
BLAKE2b-256 a9d3d47a189ad8be35ba84754ee65a5eb420fa9543ba8b462888ec2bc314177f

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e3ae4faa1b0a2a9a721ccbe83c8e80f0b7badaa21237592c67bdc99a99009a5
MD5 d8ba08112f6740ff1931f96f5aae4cea
BLAKE2b-256 6a821b8342a4371f33291c80db7576bbf8de6d86abc8f872b265fef410c9f4d4

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 656fd1e471446efc3d1ef7274749b6531282466be835fa74c735d9a3ef17d773
MD5 49e0e34f8502414e6d35d3f48baa0d89
BLAKE2b-256 317c78a8abc18e1960a3ce3c6db4b4d29f5073fa7a668cec0bb59ca2db727060

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f41eca55d8cc65cfe0025cb9eb46dfa9281c9e377cfb566991439ac9c71f3ff
MD5 e8a420a319c478ce6a29a30cc654061f
BLAKE2b-256 bcd2970e26a6206f629e969f2787d00a3c81f5a1ef13d2d92fe5fd6893bf00ef

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 39b7e1ee6fe08384240549445529e4e3e5f8a3a63b4a4184dff7b2df85c1e38d
MD5 0881a1823d23a310b6f3996ae5772180
BLAKE2b-256 5667a343bd1293f8cd4601dedbd296fca188a6a402b248ff773438283cf7db68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b3500c364fd90012927ee4690a7f8173b3a4eb19cc9000b94a5c1db75790b275
MD5 2be5d09aa380a7112d591d11bf50bb06
BLAKE2b-256 fe64606a9b526b39553f7c5776189abadd672090f24209bceb11fcd91d91c738

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 684d1b2f60ce31b5eba1695e4ec03125e8fa9d2b5e1b05e70ad25d1012e4d839
MD5 3fc862c9bed63e358de17f78d6e21b93
BLAKE2b-256 c22a9b6a770d108e7dcc7c8a871832ff680645f9486fb15c7314976015161f44

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ad5ed5d123df0ca0dd0139285670804a5cba564a81d9769ba4f8899998efe4ad
MD5 67122e9260ed68d377b5305908855907
BLAKE2b-256 9ad7ba6800e4f7190fad6600ebb791f6ea9f935f54027279e676057bc691540c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 129b34a7d4eb37a08227ae0b7d625a61b239b45f15eb4bc3a1ef12b54bd32044
MD5 2895b667c9d0da140acba3b9e6e15ff0
BLAKE2b-256 fae9bbf20dbd350b39dc518115f809dc0f10a81fc42de55b9ba1c5b134477ccc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ef9804f6025dfb080d70b13c6fa56e30cd951ec74fe6668bfe788bc42997782a
MD5 a6cdd32128f9af33d2e1502f07c42494
BLAKE2b-256 72792cab8eb081b4afbc1b52d108c1c4bc3b377ed37f4141755c48b64c90032c

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33c0ecac07b2636a882bd064ba8500f2370d8c08865a4ff7907045bbc1807b4e
MD5 71237357eecc50f5f515a4cd8487f646
BLAKE2b-256 aba0e8d2e0c8197112aaa456d3b629929b37e625f25bd5a0d15110b0b14d8890

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cde108f5165d6fa3505c3d585980c6f5360762cf56381348c344986591d0fdf5
MD5 32950c400adb1162b1e3197368858f9e
BLAKE2b-256 7b41ab672f69e5a5923bc6f2371ffc242bace38e02461421b01edfc854c44596

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c6cdb4b7a46fd5d0c3ef97cc8344f70515146d0cf0c91334b75546c448e4ba26
MD5 b3b83f9fb70ac26a2fac85d8c82f5ee6
BLAKE2b-256 b6b20583fd3dc156b7cdb41e18d87de0486987d36cb2927695d2c15a0d04ac9b

See more details on using hashes here.

File details

Details for the file ballistics_engine-0.13.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ballistics_engine-0.13.10-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 97bd05cbe8e53298e9d77c222d34dcdfda0a9e0fb5251ffa40de592403078bf0
MD5 a2f3fe82ad8c14b7e671eac302faafe4
BLAKE2b-256 bad605495657e33881e91693f1753b6fc41ef680b30c60a03bada8611b613e9f

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