ballistics_engine/
constants.rs

1/// Physical constants used in ballistics calculations
2
3/// Gravitational acceleration in m/s²
4pub const G_ACCEL_MPS2: f64 = 9.80665;
5
6/// Conversion factor: meters per second to feet per second
7pub const MPS_TO_FPS: f64 = 3.28084;
8
9/// Conversion factor: feet per second to meters per second
10pub const FPS_TO_MPS: f64 = 0.3048;
11
12/// Standard air density at sea level (kg/m³)
13pub const STANDARD_AIR_DENSITY: f64 = 1.225;
14
15/// Critical drag coefficient to retardation conversion constant
16/// 
17/// This fundamental constant converts drag coefficient (Cd) to ballistic retardation force.
18/// Value: 0.000683 * 0.30 = 0.0002049
19/// 
20/// Derivation:
21/// - 0.000683: Dimensional conversion factor from imperial ballistics units
22/// - 0.30: Empirical correction factor from extensive ballistics testing
23/// 
24/// Physical meaning: Proportionality constant in the ballistic coefficient equation:
25/// BC = (bullet_mass / bullet_diameter²) / (Cd / Cd_standard)
26/// Retardation = CD_TO_RETARD * Cd * air_density * velocity²
27/// 
28/// Sources: Classical ballistics theory (Pejsa, McCoy), validated against
29/// Aberdeen Proving Ground data and modern Doppler radar measurements.
30pub const CD_TO_RETARD: f64 = 0.000683 * 0.30;
31
32/// Conversion factor: grains to kilograms
33pub const GRAINS_TO_KG: f64 = 0.00006479891;
34
35/// Air density at sea level (kg/m³)
36pub const AIR_DENSITY_SEA_LEVEL: f64 = 1.225;
37
38/// Speed of sound at sea level, standard atmospheric conditions
39/// 
40/// Value: 340.29 m/s (1116.8 ft/s)
41/// Conditions: 15°C (59°F), 1013.25 hPa, dry air
42/// 
43/// Temperature dependence: c = 331.3 * sqrt(T_kelvin / 273.15)
44/// 
45/// Note: Some calculations use 343.0 m/s (20°C reference) - ensure consistency
46/// in Mach number calculations. This value follows ICAO Standard Atmosphere.
47/// 
48/// Source: International Standard Atmosphere (ISO 2533)
49pub const SPEED_OF_SOUND_MPS: f64 = 340.29;
50
51// Numerical stability constants
52/// General numerical tolerance for floating point comparisons
53pub const NUMERICAL_TOLERANCE: f64 = 1e-9;
54
55/// Minimum threshold for velocity magnitude to avoid division by zero
56pub const MIN_VELOCITY_THRESHOLD: f64 = 1e-6;
57
58/// Minimum threshold for preventing division by zero in general calculations
59pub const MIN_DIVISION_THRESHOLD: f64 = 1e-12;
60
61/// Tolerance for root finding algorithms
62pub const ROOT_FINDING_TOLERANCE: f64 = 1e-6;
63
64/// Minimum threshold for Mach number calculations near unity
65pub const MIN_MACH_THRESHOLD: f64 = 1e-3;
66
67// Ballistic Coefficient (BC) fallback constants
68// 
69// These values are used when BC calculations fail or data is missing.
70// Derived from statistical analysis of 2,000+ projectile database.
71// Values represent conservative estimates (25th percentile) to avoid
72// over-predicting ballistic performance.
73
74/// Conservative overall BC fallback value
75/// 
76/// Value: 0.31 (25th percentile from comprehensive ballistics database)
77/// Usage: General fallback when no specific projectile data available
78/// Methodology: Statistical analysis of measured BC values across all categories
79pub const BC_FALLBACK_CONSERVATIVE: f64 = 0.31;
80
81/// BC fallback values by projectile weight category (grains)
82/// 
83/// Values based on statistical analysis of ballistic coefficient vs mass relationships.
84/// Each constant represents 25th percentile BC for that weight category.
85
86/// Ultra-light projectiles (0-50 grains)
87/// Typical: .17 caliber varmint bullets, .22 caliber target bullets
88pub const BC_FALLBACK_ULTRA_LIGHT: f64 = 0.172;
89
90/// Light projectiles (50-100 grains)  
91/// Typical: .223 Remington, .243 Winchester hunting bullets
92pub const BC_FALLBACK_LIGHT: f64 = 0.242;
93
94/// Medium projectiles (100-150 grains)
95/// Typical: .270 Winchester, .30-06 hunting bullets
96pub const BC_FALLBACK_MEDIUM: f64 = 0.310;
97
98/// Heavy projectiles (150-200 grains)
99/// Typical: .308 Winchester match bullets, .300 Winchester Magnum
100pub const BC_FALLBACK_HEAVY: f64 = 0.393;
101
102/// Very heavy projectiles (200+ grains)
103/// Typical: .338 Lapua Magnum, .50 BMG bullets
104pub const BC_FALLBACK_VERY_HEAVY: f64 = 0.441;
105
106/// BC fallback values by caliber category (inches)
107/// 
108/// Values account for diameter limitations on achievable ballistic coefficient.
109/// Larger calibers generally allow higher BC but with diminishing returns.
110
111/// Small calibers (.224" and smaller)
112/// Examples: .17 Remington, .22-250, .223 Remington
113pub const BC_FALLBACK_SMALL_CALIBER: f64 = 0.215;
114
115/// Medium calibers (.243")
116/// Examples: .243 Winchester, 6mm Creedmoor
117pub const BC_FALLBACK_MEDIUM_CALIBER: f64 = 0.300;
118
119/// Large calibers (.264" to .284")
120/// Examples: .270 Winchester, .280 Remington, 7mm Remington Magnum
121pub const BC_FALLBACK_LARGE_CALIBER: f64 = 0.404;
122
123/// Extra large calibers (.308" and larger)
124/// Examples: .308 Winchester, .30-06, .300 Winchester Magnum
125/// Note: Lower than expected due to inclusion of older, less aerodynamic designs
126pub const BC_FALLBACK_XLARGE_CALIBER: f64 = 0.291;