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 coefficientbullet_weight_grains(float): Bullet mass in grainsmuzzle_velocity_fps(float): Muzzle velocity in fpsbullet_diameter_inches(float): Bullet diameter in inchesbullet_length_inches(float): Bullet length in inchessight_height_inches(float): Sight height above bore in incheszero_distance_yards(float): Zero distance in yardsshooting_angle_degrees(float): Uphill/downhill angle in degreestwist_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 inputssolve(): Calculate trajectory, returnsTrajectoryResult
TrajectoryResult
Trajectory calculation results.
Properties:
max_range_yards(float): Maximum range in yardsmax_height_yards(float): Maximum height in yardstime_of_flight(float): Total flight time in secondsimpact_velocity_fps(float): Impact velocity in fpsimpact_energy_ftlbs(float): Impact energy in ft-lbspoints(list[TrajectoryPoint]): List of trajectory points
TrajectoryPoint
Individual point along trajectory.
Properties:
time(float): Time in secondsx(float): Downrange distance in yardsy(float): Vertical position in yards (relative to line of sight)z(float): Lateral position in yardsvelocity_fps(float): Velocity in fpsenergy_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
- Homepage: https://ballistics.rs/
- Repository: https://github.com/ajokela/ballistics-engine
- Documentation: https://docs.rs/ballistics-engine
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ballistics_engine-0.13.17.tar.gz.
File metadata
- Download URL: ballistics_engine-0.13.17.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38952ca460018805ba81f677f4d4ee5ff02d158471bc0321fd9441b37146810d
|
|
| MD5 |
befa379ee2e41107ee07c39495a928d7
|
|
| BLAKE2b-256 |
1bb3551f85829b71b8d8955d04383cd97483cc758ee10b30307c9b9935570f53
|
File details
Details for the file ballistics_engine-0.13.17-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 446.6 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36dfd2a8a09689bf71acfca2144ad3390c1387d53a8ae81f014745fe1dfb00b2
|
|
| MD5 |
26e0f2ed86349221e2da032fb89ea359
|
|
| BLAKE2b-256 |
3db3d847bd16717b0fd07eeaf36500a95e53ea885bfc5ec155f75a55434839c3
|
File details
Details for the file ballistics_engine-0.13.17-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 439.6 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b3f355cb1325b8cb0f7fe9fe6cf99e031855e1618a027c6d581c9268e9a50a3
|
|
| MD5 |
757805bd8562dad03b3ec6403b8a9d3f
|
|
| BLAKE2b-256 |
0f0aabd9d90b55627e664538ef7fb4e9bd867f9eec65ab4c27b85ff293641b65
|
File details
Details for the file ballistics_engine-0.13.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 447.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
216af5540ab66eb82acb43ff29920cc5c4140ae73750efc1311b2462df77295a
|
|
| MD5 |
0754c2d4b287f065015b672fe040e2f2
|
|
| BLAKE2b-256 |
72749fda1c693acfc9830a3a2739396bc27286d5851e565de6fa3891e5154323
|
File details
Details for the file ballistics_engine-0.13.17-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 440.0 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4531e2bd2cc8a9ca48031ac65392d971755d9768c36e59f1d751a2523fe4e368
|
|
| MD5 |
6aaaafc34c511ac63e8054e05d7c182b
|
|
| BLAKE2b-256 |
988e8728583977c7f4dc2795666d82c6408b5bab4b644fe3908bed23fc69a773
|
File details
Details for the file ballistics_engine-0.13.17-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 350.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbad29ad85a3cfc701c2451fd83e744af10828668826cb395ada225dea08e796
|
|
| MD5 |
d0b5dd7c8f6f7218c267941bee9f5033
|
|
| BLAKE2b-256 |
c7f51cd834c6fe03863a6387e72a48092ba3b513b0afda1755a6f700ac06b1cc
|
File details
Details for the file ballistics_engine-0.13.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 446.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ac64b3d6d7610ba3d36ff5c8160c733f81651a17e4d3a1730a0f3f9228e8232
|
|
| MD5 |
18eb1ec16009bb8baa8117eb3e8ace18
|
|
| BLAKE2b-256 |
98aa906164fa9e39bfd5a0851076f5e4861e9e345cd2373ffdd8371e7c82b552
|
File details
Details for the file ballistics_engine-0.13.17-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 439.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3e3f52bdf8c1a793ff5ead60bf418225405ea358e6851e81e2939ed5836a85c
|
|
| MD5 |
86a47550ce6057be6eaa9c98ca2918b3
|
|
| BLAKE2b-256 |
23f494de2dd392ef34c2861ebf8972c703421416dae3ca308863587d8f73abd4
|
File details
Details for the file ballistics_engine-0.13.17-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 410.5 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f9be7375a2ba493e103d77aa85a907be8c261d8eab2f1b7e4cef27f821b2fc5
|
|
| MD5 |
442641039f7e095e9b5b2c2cbbe884a9
|
|
| BLAKE2b-256 |
b116ed18fb19f14eec96e6316e9cb40ff1e1c4e204f8ed0d94d3c23a74bf8ae1
|
File details
Details for the file ballistics_engine-0.13.17-cp311-cp311-macosx_10_12_x86_64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 423.6 kB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4b0d49483c38067e93dd079ef92838c3f5ad0a4ffd0b9b5cbd15d9ee65e157e
|
|
| MD5 |
f1c1398ab7548df86939e90eb29551d3
|
|
| BLAKE2b-256 |
b4bb693118b3ca8460e377ce1278ffffe875988c5102a1536b98553948d73df5
|
File details
Details for the file ballistics_engine-0.13.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 446.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e41b5e6bb261d62d1b11904ec54a03526425f58e3c437897a28504a785bbdfc
|
|
| MD5 |
1fe6fdf4afdf11e6edd6d6ff0bde823a
|
|
| BLAKE2b-256 |
e4618d0e7dcec08b35e0df06f74729f000919b2bb6aa841167cdf7f9884f0681
|
File details
Details for the file ballistics_engine-0.13.17-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 439.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77038bca39924eb548140eadf7deed3aca2c90f8bf63e3b256d989b2d1a4e34e
|
|
| MD5 |
061be474b5a6187fca13c9c87ba572c5
|
|
| BLAKE2b-256 |
c89d8c4d79911aa4710e53ac1ea8e4c47196aaf283ef56876831cecb314d72a8
|
File details
Details for the file ballistics_engine-0.13.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 446.6 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3cf32c524320ea86ada5e0e605048ce1d0a615ebea439d3835f7127129605a8
|
|
| MD5 |
fe7e23d6adad87c6c542115eb8b4803d
|
|
| BLAKE2b-256 |
febb93463848b78f14c0e965329ebe53734a9ec27cdf97756f12e6d3dbfe21db
|
File details
Details for the file ballistics_engine-0.13.17-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ballistics_engine-0.13.17-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 440.1 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
effdaa63551345e6c7e34b194d30e8237cf57dffaa3baf5ca90aead682c2e7a9
|
|
| MD5 |
2c9a3b5d6b76dc4061f5a6e4ade247b0
|
|
| BLAKE2b-256 |
97b341e908eadcabf4fc9880e699f9edbda8d90db5efcb3e5d0dcc48bcf430a9
|