# Ballistics Engine CLI Tool
Comprehensive command-line interface for professional ballistics trajectory calculations with advanced drag modeling and automatic zeroing.
## Installation
```bash
# Build from source
cargo build --release
# Binary location
./target/release/ballistics
```
## Unit Systems
The CLI supports two unit systems, selectable with the `--units` flag (default: Imperial)
### Imperial Units (Default)
- Velocity: feet per second (fps)
- Mass: grains
- Distance: yards
- Diameter: inches
- Temperature: Fahrenheit
- Pressure: inHg
### Metric Units
- Velocity: meters per second (m/s)
- Mass: grams
- Distance: meters
- Diameter: millimeters
- Temperature: Celsius
- Pressure: hPa
## Commands
### Trajectory Calculation
Calculate ballistic trajectories with advanced physics modeling:
```bash
# Basic trajectory (Imperial - default)
./ballistics trajectory -v 2700 -b 0.475 -m 168 -d 0.308
# With automatic zeroing at 200 yards
./ballistics trajectory -v 2700 -b 0.475 -m 168 -d 0.308 --auto-zero 200
# Metric units
./ballistics trajectory --units metric -v 823 -b 0.475 -m 10.9 -d 7.82
# Full example with environmental conditions
./ballistics trajectory \
-v 2700 # Velocity (fps)
-b 0.475 # Ballistic coefficient
-m 168 # Mass (grains)
-d 0.308 # Diameter (inches)
--drag-model g7 # G7 drag model
--auto-zero 200 # Zero at 200 yards
--max-range 1000 # Max range (yards)
--wind-speed 10 # Wind (mph)
--wind-direction 90 # Wind from right
--temperature 59 # Temp (°F)
--pressure 29.92 # Pressure (inHg)
--humidity 50 # Humidity (%)
--altitude 5000 # Altitude (feet)
--full # Show all points
```
#### Advanced BC Options
```bash
# Enable velocity-based BC segmentation
./ballistics trajectory -v 2700 -b 0.475 -m 168 -d 0.308 \
--use-bc-segments \
--auto-zero 600
# Enable cluster-based BC degradation (auto-detects bullet type)
./ballistics trajectory -v 2700 -b 0.475 -m 168 -d 0.308 \
--use-cluster-bc \
--auto-zero 600
# Manual cluster selection
./ballistics trajectory -v 3000 -b 0.250 -m 55 -d 0.224 \
--use-cluster-bc \
--bullet-cluster 2 # Light Varmint cluster
```
### Zero Calculation
Calculate sight adjustments for specific distances:
```bash
# Calculate zero for 200 yards
./ballistics zero -v 2700 -b 0.475 -m 168 -d 0.308 --target-distance 200
# With custom sight height
./ballistics zero -v 2700 -b 0.475 -m 168 -d 0.308 \
--target-distance 300 \
--sight-height 0.055 # 2.2 inches in yards
# Metric
./ballistics zero --units metric -v 823 -b 0.475 -m 10.9 -d 7.82 \
--target-distance 200 # 200 meters
```
Output provides:
- Zero angle in degrees
- MOA adjustment
- Mrad adjustment
- Maximum ordinate
### Monte Carlo Simulation
Statistical analysis with parameter variations:
```bash
# Basic Monte Carlo
./ballistics monte-carlo -v 2700 -b 0.475 -m 168 -d 0.308 -n 1000
# With variations and target distance
./ballistics monte-carlo \
-v 2700 # Base velocity (fps)
-b 0.475 # Base BC
-m 168 # Mass (grains)
-d 0.308 # Diameter (inches)
-n 1000 # Simulations
--velocity-std 10 # Velocity std dev
--angle-std 0.5 # Angle std dev
--bc-std 0.01 # BC std dev
--wind-std 2 # Wind std dev
--target-distance 600 # For hit probability
```
### BC Estimation
Estimate ballistic coefficient from observed trajectory:
```bash
./ballistics estimate-bc \
-v 2700 -m 168 -d 0.308 \
--distance1 100 --drop1 0.0 \
--distance2 200 --drop2 0.023
```
## Output Formats
All commands support three output formats via `-o`:
### Table Format (default)
```bash
./ballistics trajectory -v 2700 -b 0.475 -m 168 -d 0.308 -o table
```
### JSON Format
```bash
./ballistics trajectory -v 2700 -b 0.475 -m 168 -d 0.308 -o json > trajectory.json
```
### CSV Format
```bash
./ballistics trajectory -v 2700 -b 0.475 -m 168 -d 0.308 -o csv > trajectory.csv
```
## Parameters Reference
### Trajectory Command
| -v, --velocity | Muzzle velocity | Required | fps | m/s |
| -a, --angle | Launch angle | 0.0° | degrees | degrees |
| -b, --bc | Ballistic coefficient | Required | - | - |
| -m, --mass | Projectile mass | Required | grains | grams |
| -d, --diameter | Projectile diameter | Required | inches | mm |
| --drag-model | Drag model (g1/g7) | g1 | - | - |
| --auto-zero | Auto-zero distance | None | yards | meters |
| --sight-height | Sight height above bore | 0.05 | yards | meters |
| --max-range | Maximum range | 1000 | yards | meters |
| --time-step | Integration time step | 0.001 | seconds | seconds |
| --wind-speed | Wind speed | 0 | mph | m/s |
| --wind-direction | Wind direction | 0° | degrees | degrees |
| --temperature | Temperature | 59 | °F | °C |
| --pressure | Barometric pressure | 29.92 | inHg | hPa |
| --humidity | Relative humidity | 50 | % | % |
| --altitude | Altitude | 0 | feet | meters |
| --use-bc-segments | Enable BC segmentation | false | - | - |
| --use-cluster-bc | Enable cluster BC | false | - | - |
| --bullet-cluster | Manual cluster (0-3) | Auto | - | - |
| --full | Show all trajectory points | false | - | - |
### Cluster Types
| 0 | Standard Long-Range | .308 Match, .30-06 | Gradual degradation |
| 1 | Low-Drag Specialty | 6.5mm VLD, 6mm BR | Maintains BC well |
| 2 | Light Varmint | .223 55gr, .204 | Steep BC loss |
| 3 | Heavy Magnums | .338 Lapua, .50 BMG | Moderate degradation |
## Practical Examples
### Hunting Zero at 200 Yards
```bash
# Calculate zero
./ballistics zero -v 2650 -b 0.460 -m 180 -d 0.308 --target-distance 200
# Verify with trajectory
./ballistics trajectory -v 2650 -b 0.460 -m 180 -d 0.308 \
--auto-zero 200 --max-range 400 --full
```
### Long Range Precision
```bash
./ballistics trajectory \
-v 2850 -b 0.690 -m 230 -d 0.338 \
--drag-model g7 \
--use-bc-segments \
--auto-zero 100 \
--max-range 1500 \
--wind-speed 10 \
--wind-direction 270 \
--altitude 5000 \
--full
```
### Load Development Comparison
```bash
# Load 1: Higher velocity
./ballistics monte-carlo -v 2750 -b 0.475 -m 168 -d 0.308 \
-n 1000 --velocity-std 15 --target-distance 600
# Load 2: More consistent
./ballistics monte-carlo -v 2680 -b 0.475 -m 168 -d 0.308 \
-n 1000 --velocity-std 8 --target-distance 600
```
### Varmint Trajectory with Cluster BC
```bash
./ballistics trajectory \
-v 3200 -b 0.242 -m 55 -d 0.224 \
--use-cluster-bc \
--bullet-cluster 2 \
--auto-zero 200 \
--max-range 500
```
### Extreme Weather Conditions
```bash
# Cold, low pressure, high humidity (poor conditions)
./ballistics trajectory \
-v 2700 -b 0.475 -m 168 -d 0.308 \
--auto-zero 100 \
--temperature -10 \ # Very cold
--pressure 28.50 \ # Low pressure storm
--humidity 95 \ # Near saturation
--altitude 7000 \ # High altitude
--max-range 500
# Hot, dry, high pressure (good conditions)
./ballistics trajectory \
-v 2700 -b 0.475 -m 168 -d 0.308 \
--auto-zero 100 \
--temperature 95 \ # Hot day
--pressure 30.50 \ # High pressure
--humidity 10 \ # Very dry
--altitude 0 \ # Sea level
--max-range 500
```
## Advanced Features
### Drag Models
- **G1**: Standard projectile (most common)
- **G7**: Boat-tail bullets (better for long range)
- Full drag tables with Mach-indexed coefficients
- Transonic corrections applied automatically
- Reynolds number corrections for low velocities
### BC Modeling
- **BC Segmentation**: Velocity-dependent BC based on bullet type
- **Cluster BC**: ML-based classification and degradation curves
- **Form Factor**: Additional corrections for bullet shape
- Automatic bullet type identification from parameters
### Physics Engine
- 4DOF trajectory integration (3D position + time)
- Magnus effect for spin drift
- Coriolis effect (with latitude input)
- Variable atmospheric conditions
- Wind profile with altitude effects
- Ground impact detection
### Atmospheric Modeling
- **Temperature Effects**: Affects air density and speed of sound
- **Pressure Effects**: Direct impact on air density (drag)
- **Humidity Effects**:
- Humid air is less dense (reduces drag)
- Increases speed of sound slightly
- Uses Arden Buck equations for vapor pressure
- **Altitude Effects**: Automatic pressure/density reduction with elevation
- **ICAO Standard Atmosphere**: Full implementation up to 84km
- **CIPM Formula**: Precise air density calculations with humidity
## Notes
- Default units are Imperial (fps, grains, yards)
- All internal calculations use SI units for precision
- BC values are dimensionless (same for G1 and G7)
- Wind direction: 0° = headwind, 90° = from right, 180° = tailwind, 270° = from left
- Trajectory stops at ground impact or max range
- Sight height default is 1.8 inches (0.05 yards) above bore