CLI Documentation

Complete reference for the ballistics-engine command line interface

Installation

Using Cargo (Recommended)

cargo install ballistics-engine

From Source

git clone https://github.com/ajokela/ballistics-engine
cd ballistics-engine
cargo build --release
# Binary at ./target/release/ballistics

With Online Features

Enable API integration and BC table auto-download:

cargo install ballistics-engine --features online

Quick Start

Calculate a basic trajectory for a .308 Winchester:

ballistics trajectory \
  --velocity 2800 \
  --bc 0.462 \
  --mass 168 \
  --diameter 0.308 \
  --drag-model g1 \
  --max-range 1000 \
  --auto-zero 100

Commands

trajectory

Calculate a single ballistic trajectory with full physics modeling.

ballistics trajectory [OPTIONS]

Required Parameters

OptionDescription
-v, --velocityMuzzle velocity (fps or m/s)
-b, --bcBallistic coefficient
-m, --massBullet mass (grains or grams)
-d, --diameterBullet diameter (inches or mm)

Common Options

OptionDefaultDescription
--drag-modelg1Drag model (g1, g7)
--max-range1000Maximum range (yards or meters)
--auto-zero-Zero distance (overrides --angle)
--sight-height1.5"Scope height above bore
-o, --outputtableOutput format (table, json, csv)
--unitsimperialUnit system (imperial, metric)

Environmental Conditions

OptionDefaultDescription
--temperature59°FAir temperature
--pressure29.92 inHgBarometric pressure
--humidity50%Relative humidity
--altitude0 ftAltitude above sea level
--wind-speed0 mphWind speed
--wind-direction0°Wind from (0=N, 90=E)

Advanced Physics

OptionDescription
--enable-spin-driftCalculate gyroscopic drift
--enable-coriolisAccount for Earth's rotation
--enable-magnusInclude Magnus effect
--enable-wind-shearAltitude-dependent wind
--twist-rateBarrel twist (inches/turn)
--latitudeShooter latitude (required for Coriolis)
--longitudeShooter longitude (required for Coriolis)

monte-carlo

Run Monte Carlo simulations to analyze shot dispersion and hit probability.

ballistics monte-carlo [OPTIONS]
OptionDefaultDescription
-v, --velocityrequiredBase velocity (m/s)
-b, --bcrequiredBallistic coefficient
-m, --massrequiredMass (kg)
-d, --diameterrequiredDiameter (m)
-n, --num-sims1000Number of simulations
--velocity-std1.0Velocity std dev (m/s)
--angle-std0.1Angle std dev (degrees)
--bc-std0.01BC std dev
--wind-std1.0Wind std dev (m/s)
--target-distance-Distance for hit probability
-o, --outputsummaryOutput (summary, full, statistics)

zero

Calculate the barrel angle needed to zero at a specific distance.

ballistics zero [OPTIONS]
OptionDescription
-v, --velocityMuzzle velocity
-b, --bcBallistic coefficient
-m, --massBullet mass
-d, --diameterBullet diameter
--target-distanceZero distance
--target-heightTarget height offset (default: 0)
--sight-heightScope height above bore

estimate-bc

Estimate ballistic coefficient from observed trajectory data (two-point method).

ballistics estimate-bc [OPTIONS]
OptionDescription
-v, --velocityInitial velocity (m/s)
-m, --massMass (kg)
-d, --diameterDiameter (m)
--distance1First measurement distance (m)
--drop1Drop at distance1 (m)
--distance2Second measurement distance (m)
--drop2Drop at distance2 (m)

generate-bc-segments

Generate velocity-dependent BC segments for improved long-range accuracy.

ballistics generate-bc-segments [OPTIONS]
OptionDescription
-b, --bcBase ballistic coefficient
-m, --massMass (kg)
-d, --diameterDiameter (m)
--modelBullet model (SMK, ELD-M, VLD, etc.)
--drag-modelBase drag model (G1, G7)

true-velocity

Calculate effective muzzle velocity from observed drop data. Works in both online and offline modes. Use --offline for fully local calculation, or omit for API-based calculation (requires online feature).

ballistics true-velocity [OPTIONS]

Required Parameters

OptionDescription
--measured-dropMeasured drop in MILs at the target range
--rangeRange at which drop was measured
-b, --bcBallistic coefficient
-m, --massBullet weight (grains)
-d, --diameterBullet diameter/caliber (inches)

Optional Parameters

OptionDefaultDescription
--drag-modelg1Drag model (g1, g7)
--chrono-velocity-Chronograph velocity for comparison
--zero-range100Zero distance (yards)
--sight-height2.0Sight height above bore (inches)
--bullet-lengthautoBullet length (inches) for BC5D lookup
--temperature59Temperature (°F)
--pressure29.92Barometric pressure (inHg)
--humidity50Humidity (%)
--altitude0Altitude (feet)

Mode Parameters

OptionDefaultDescription
--offlinefalseForce offline mode (local calculation)
--offline-fallbackfalseTry API first, fall back to local if fails
--bc-table-dir-Directory with BC5D tables for improved accuracy
--bc-table-autofalseAuto-download BC5D tables (requires online feature)

Examples

# Offline calculation (no network required)
ballistics true-velocity \
  --measured-drop 5.1 \
  --range 600 \
  --bc 0.27 \
  --drag-model g7 \
  --mass 140 \
  --diameter 0.264 \
  --offline

# With chronograph comparison
ballistics true-velocity \
  --measured-drop 5.1 \
  --range 600 \
  --bc 0.27 \
  --drag-model g7 \
  --mass 140 \
  --diameter 0.264 \
  --chrono-velocity 2822 \
  --offline

# With BC5D tables for improved accuracy
ballistics true-velocity \
  --measured-drop 5.1 \
  --range 600 \
  --bc 0.27 \
  --drag-model g7 \
  --mass 140 \
  --diameter 0.264 \
  --bc-table-auto \
  --offline

Output shows the effective muzzle velocity that produces the measured drop, the adjustment from your chronograph reading (if provided), confidence level, and convergence details.

Unit Systems

The CLI supports both imperial and metric units. Use --units metric or --units imperial (default).

MeasurementImperialMetric
Velocityfps (feet/sec)m/s
Massgrainsgrams
Distanceyardsmeters
Diameterinchesmillimeters
TemperatureFahrenheitCelsius
PressureinHghPa
Altitudefeetmeters
Windmphm/s

Profiles

Save common configurations in CSV files for quick loading.

Gun Profile (gun_profiles.csv)

name,velocity,bc,mass,diameter,drag_model,twist_rate,sight_height
R700_65CM,2750,0.271,140,0.264,g7,8,1.6
AR15_223,3200,0.243,77,0.224,g7,7,2.6
M1A_308,2650,0.462,168,0.308,g1,12,1.5

Location Profile (locations.csv)

name,altitude,temperature,pressure,humidity,latitude,longitude
HOME_RANGE,500,72,29.85,45,45.5,-122.6
HIGH_DESERT,4500,85,26.5,15,35.2,-106.7
ALASKA,200,35,30.1,60,61.2,-149.9

Using Profiles

# Load gun profile
ballistics trajectory --profile gun_profiles.csv --profile-row R700_65CM --max-range 1000

# Load both gun and location profiles
ballistics trajectory \
  --profile gun_profiles.csv --profile-row R700_65CM \
  --location locations.csv --site HIGH_DESERT \
  --max-range 1500

BC Tables

BC5D tables provide velocity-dependent BC corrections for improved accuracy, especially in transonic regions.

Note: BC5D tables require the online feature for auto-download, or can be used offline with local files.

Auto-Download (Online Feature)

# Auto-download BC5D table for your caliber
ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --drag-model g7 --max-range 1500 \
  --bc-table-auto

Local BC5D Tables

# Use locally stored BC5D tables
ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --drag-model g7 --max-range 1500 \
  --bc-table-dir ~/.ballistics/bc5d/

Available Calibers

BC5D tables are available for: .224, .243, .264, .277, .284, .308, .338

Advanced Features

Spin Drift

ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --twist-rate 8 --twist-right true \
  --enable-spin-drift \
  --max-range 1000

Coriolis Effect

ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --latitude 45.5 --longitude -122.6 --shot-direction 90 \
  --enable-coriolis \
  --max-range 1500

Uphill/Downhill Shooting

# Shooting uphill at 15 degrees
ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --shooting-angle 15 \
  --max-range 800

Powder Temperature Sensitivity

ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --use-powder-sensitivity \
  --powder-temp-sensitivity 1.5 \
  --powder-temp 95 \
  --temperature 95

Online Mode

With the online feature enabled, calculations can be routed through the API for ML-enhanced corrections.

# Use online API for trajectory
ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --online \
  --max-range 1500

# Compare local vs API results
ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --compare \
  --max-range 1000

# Use online with fallback to local if API unavailable
ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --online --offline-fallback \
  --max-range 1000

Online Weather

Fetch real-time weather conditions for your location instead of manually entering temperature, pressure, and humidity. Requires latitude and longitude coordinates.

# Fetch current weather for your location
ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --latitude 45.5 --longitude -122.6 \
  --online-weather \
  --max-range 1000

# Combine online weather with Coriolis correction
ballistics trajectory \
  --velocity 2750 --bc 0.271 --mass 140 --diameter 0.264 \
  --latitude 45.5 --longitude -122.6 \
  --online-weather \
  --enable-coriolis --shot-direction 90 \
  --max-range 1500

Tip: When using --online-weather, the API fetches current temperature, barometric pressure, humidity, and density altitude for the specified coordinates. Any manually specified weather parameters will be overridden.

Output Formats

Table (Default)

ballistics trajectory ... -o table

Range    Drop     Drift    Velocity  Energy    Time
(yd)     (in)     (in)     (fps)     (ft-lb)   (s)
────────────────────────────────────────────────────
0        -1.50    0.00     2750      2351      0.000
100      0.00     0.12     2583      2074      0.113
200      -3.42    0.49     2421      1822      0.232
...

CSV

ballistics trajectory ... -o csv

range_yd,drop_in,drift_in,velocity_fps,energy_ftlb,time_s
0,-1.50,0.00,2750,2351,0.000
100,0.00,0.12,2583,2074,0.113
...

JSON

ballistics trajectory ... -o json

{
  "trajectory": [
    {"range": 0, "drop": -1.50, "drift": 0.0, "velocity": 2750, ...},
    ...
  ],
  "summary": {
    "max_range": 1000,
    "zero_range": 100,
    ...
  }
}

Complete Examples

6.5 Creedmoor at 1000 Yards

ballistics trajectory \
  --velocity 2750 \
  --bc 0.271 \
  --mass 140 \
  --diameter 0.264 \
  --drag-model g7 \
  --max-range 1000 \
  --auto-zero 100 \
  --sight-height 1.6 \
  --twist-rate 8 \
  --enable-spin-drift \
  --temperature 72 \
  --altitude 500 \
  --wind-speed 10 \
  --wind-direction 90 \
  -o table

.308 Winchester Long Range

ballistics trajectory \
  --velocity 2650 \
  --bc 0.462 \
  --mass 175 \
  --diameter 0.308 \
  --drag-model g1 \
  --max-range 1200 \
  --auto-zero 100 \
  --altitude 4000 \
  --temperature 55 \
  --pressure 26.5 \
  --enable-spin-drift \
  --twist-rate 10 \
  --bc-table-auto

Monte Carlo Hit Probability

ballistics monte-carlo \
  --velocity 838 \
  --bc 0.271 \
  --mass 0.00907 \
  --diameter 0.00671 \
  --num-sims 10000 \
  --velocity-std 3.0 \
  --angle-std 0.05 \
  --wind-speed 4.5 \
  --wind-std 2.0 \
  --target-distance 914 \
  -o statistics

BC Estimation from Field Data

ballistics estimate-bc \
  --velocity 838 \
  --mass 0.00907 \
  --diameter 0.00671 \
  --distance1 300 \
  --drop1 0.45 \
  --distance2 600 \
  --drop2 2.1