ballistics_engine/lib.rs
1//! # Ballistics Engine
2//!
3//! High-performance ballistics trajectory calculation engine with comprehensive physics modeling.
4//!
5//! ## Interactive Web Demo
6//!
7//! Try the ballistics engine directly in your browser at [https://ballistics.rs/](https://ballistics.rs/)
8//!
9//! ## Features
10//!
11//! - Professional-grade trajectory calculations with multiple drag models
12//! - Advanced physics including spin drift, Coriolis effect, and Magnus force
13//! - Monte Carlo simulations for uncertainty analysis
14//! - WebAssembly support for browser-based applications
15//! - FFI bindings for iOS and Android development
16
17// Re-export the main types and functions
18pub use cli_api::{
19 calculate_zero_angle, calculate_zero_angle_with_conditions,
20 calculate_zero_angle_with_resolved_conditions, calculate_zero_range_from_angle_with_conditions,
21 calculate_zero_range_from_angle_with_resolved_conditions, estimate_bc_fit,
22 estimate_bc_from_trajectory, interpolate_powder_temp_curve,
23 resolve_powder_adjusted_velocity, run_monte_carlo, run_monte_carlo_with_direction_std_dev,
24 run_monte_carlo_with_wind, run_monte_carlo_with_wind_and_direction_std_dev,
25 run_monte_carlo_with_wind_and_direction_std_dev_seeded, AtmosphericConditions,
26 BallisticInputs, BallisticsError, BcEstimate, BcFitMode, BcReferenceStandard,
27 MonteCarloParams, MonteCarloResults, TrajectoryPoint, TrajectoryResult, TrajectorySolver,
28 WindConditions, ZeroCrossings, DEFAULT_HIT_RADIUS_M, MAX_TRAJECTORY_POINTS,
29 TARGET_NOT_REACHED_SENTINEL_M,
30};
31pub use atmosphere::{AtmoSegment, AtmoSock};
32pub use drag_model::DragModel;
33pub use moving_target::{
34 calculate_lead, lead_from_tof, mover_ring, LeadComponents, LeadError, LeadSolution,
35};
36pub use solve_json::{
37 decode_solve_request_v1, ResolvedSolveRequestV1, SolveErrorCodeV1, SolveErrorEnvelopeV1,
38 SolveRequestV1, SolveSuccessV1, MAX_SOLVE_JSON_SAMPLES_V1, SOLVE_JSON_SCHEMA_VERSION_V1,
39};
40pub use solve_v1::solve_v1;
41pub use trajectory_observation::{
42 TrajectoryObservation, TrajectoryObservationError, TrajectoryObservationFlag,
43 TrajectoryTermination,
44};
45pub use trajectory_sampling::MAX_TRAJECTORY_SAMPLES;
46
47// Module declarations
48pub mod cli_api;
49pub mod moving_target;
50mod drag_model;
51// The C ABI. Gated behind the default-on `ffi` feature so a binary that links two versions of
52// this crate can disable it on one edge and avoid duplicate #[no_mangle] symbols.
53#[cfg(feature = "ffi")]
54pub mod ffi;
55pub mod solve_json;
56pub mod solve_v1;
57pub mod terminal_plot;
58// MBA-1343: multi-observation velocity/BC truing core, shared by the CLI and the WASM terminal.
59pub mod truing;
60// MBA-1346: observation-range experiment design for identifiable MV/BC truing.
61pub mod truing_plan;
62// MBA-1353: opt-in uncertainty-aware joint MV/BC truing.
63pub mod truing_uncertainty;
64// MBA-1357: Mach-keyed DSF (drop-scale-factor) truing table — a drop-only post-processing
65// correction applied to a solved TrajectoryResult. No feature gate: must compile for wasm32;
66// fs-free (profile persistence lives in main.rs).
67pub mod truing_dsf;
68// MBA-1343 Phase B: WEZ (`monte-carlo --wez`) sweep core, shared by the CLI and the WASM terminal.
69pub mod wez;
70// MBA-1355: turret adjustment-unit conversions (SMOA/IPHY/clicks) and click-value parsing,
71// shared by the CLI and the WASM terminal. No feature gate: must compile for wasm32.
72pub mod adjustment;
73// MBA-1409: cleanroom `.drg` (Doppler drag-curve text file) parser, shared by the CLI and
74// the WASM terminal. No feature gate: must compile for wasm32; parses TEXT only (no
75// std::fs — file I/O stays in main.rs/wasm.rs).
76pub mod drag_file;
77// MBA-1372: SAAMI free-recoil momentum-balance calculator, shared by the CLI and the
78// WASM terminal. No feature gate: must compile for wasm32; pure math, no I/O.
79pub mod recoil;
80// MBA-1372: power-factor arithmetic and per-organization (USPSA/IDPA/SASS) rulebook
81// pass/fail thresholds, shared by the CLI and the WASM terminal. No feature gate: must
82// compile for wasm32; pure math + a data table, no I/O.
83pub mod power_factor;
84pub mod trajectory_observation;
85#[cfg(target_arch = "wasm32")]
86pub mod wasm;
87#[cfg(test)]
88mod wasm_tests;
89// MBA-154: Make constants public for ballistics_rust wrapping
90pub mod atmosphere;
91pub mod constants;
92pub mod drag;
93pub mod wind;
94// MBA-153: Make wind_shear public for ballistics_rust wrapping
95pub mod wind_shear;
96// MBA-154: Make derivatives public for ballistics_rust wrapping
97pub mod derivatives;
98pub mod trajectory_sampling;
99// MBA-154: Make fast_trajectory public for ballistics_rust wrapping
100pub mod fast_trajectory;
101// MBA-155: Add advanced integration methods (RK4, RK45)
102pub mod trajectory_integration;
103// MBA-149 Phase 5 Priority 2: Export enhanced spin_drift
104pub mod pitch_damping;
105pub mod spin_decay;
106pub mod spin_drift;
107pub mod spin_drift_advanced;
108// MBA-149 Phase 5 Priority 2: Export enhanced precession_nutation
109pub mod precession_nutation;
110// MBA-153: Make aerodynamic_jump public for ballistics_rust wrapping
111pub mod aerodynamic_jump;
112// MBA-149 Phase 5 Priority 2: Export enhanced angle_calculations
113pub mod angle_calculations;
114pub mod transonic_drag;
115// MBA-153: Make reynolds public for ballistics_rust wrapping
116pub mod reynolds;
117// MBA-149 Phase 5 Priority 2: Export enhanced form_factor
118pub mod form_factor;
119// MBA-153: Make monte_carlo public for ballistics_rust wrapping
120pub mod bc_estimation;
121pub mod cluster_bc;
122pub mod monte_carlo;
123pub mod stability;
124pub mod stability_advanced;
125
126// Online mode: HTTP client for Flask API (feature-gated)
127#[cfg(feature = "online")]
128pub mod api_client;
129
130// BC5D table auto-download (feature-gated)
131#[cfg(feature = "online")]
132pub mod bc_table_download;
133
134// BC correction table for offline mode
135pub mod bc_table;
136
137// 5D BC correction tables (caliber-specific, ML-derived)
138pub mod bc_table_5d;
139
140// Import of third-party ballistic profile files (.a7p), feature-gated
141#[cfg(feature = "profile-import")]
142pub mod profile_import;
143
144// Internal type alias for compatibility
145pub(crate) type InternalBallisticInputs = BallisticInputs;
146
147// BC segment data for velocity-dependent BC
148#[derive(Debug, Clone)]
149pub struct BCSegmentData {
150 pub velocity_min: f64,
151 pub velocity_max: f64,
152 pub bc_value: f64,
153}