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, estimate_bc_fit,
20    estimate_bc_from_trajectory, interpolate_powder_temp_curve,
21    resolve_powder_adjusted_velocity, run_monte_carlo, run_monte_carlo_with_direction_std_dev,
22    run_monte_carlo_with_wind, run_monte_carlo_with_wind_and_direction_std_dev,
23    run_monte_carlo_with_wind_and_direction_std_dev_seeded, AtmosphericConditions,
24    BallisticInputs, BallisticsError, BcEstimate, BcFitMode, MonteCarloParams,
25    MonteCarloResults, TrajectoryPoint, TrajectoryResult, TrajectorySolver, WindConditions,
26    DEFAULT_HIT_RADIUS_M, MAX_TRAJECTORY_POINTS, TARGET_NOT_REACHED_SENTINEL_M,
27};
28pub use atmosphere::{AtmoSegment, AtmoSock};
29pub use drag_model::DragModel;
30pub use moving_target::{
31    calculate_lead, lead_from_tof, mover_ring, LeadComponents, LeadError, LeadSolution,
32};
33pub use solve_json::{
34    decode_solve_request_v1, ResolvedSolveRequestV1, SolveErrorCodeV1, SolveErrorEnvelopeV1,
35    SolveRequestV1, SolveSuccessV1, MAX_SOLVE_JSON_SAMPLES_V1, SOLVE_JSON_SCHEMA_VERSION_V1,
36};
37pub use solve_v1::solve_v1;
38pub use trajectory_observation::{
39    TrajectoryObservation, TrajectoryObservationError, TrajectoryObservationFlag,
40    TrajectoryTermination,
41};
42pub use trajectory_sampling::MAX_TRAJECTORY_SAMPLES;
43
44// Module declarations
45pub mod cli_api;
46pub mod moving_target;
47mod drag_model;
48// The C ABI. Gated behind the default-on `ffi` feature so a binary that links two versions of
49// this crate can disable it on one edge and avoid duplicate #[no_mangle] symbols.
50#[cfg(feature = "ffi")]
51pub mod ffi;
52pub mod solve_json;
53pub mod solve_v1;
54pub mod terminal_plot;
55// MBA-1343: multi-observation velocity/BC truing core, shared by the CLI and the WASM terminal.
56pub mod truing;
57// MBA-1346: observation-range experiment design for identifiable MV/BC truing.
58pub mod truing_plan;
59// MBA-1353: opt-in uncertainty-aware joint MV/BC truing.
60pub mod truing_uncertainty;
61// MBA-1357: Mach-keyed DSF (drop-scale-factor) truing table — a drop-only post-processing
62// correction applied to a solved TrajectoryResult. No feature gate: must compile for wasm32;
63// fs-free (profile persistence lives in main.rs).
64pub mod truing_dsf;
65// MBA-1343 Phase B: WEZ (`monte-carlo --wez`) sweep core, shared by the CLI and the WASM terminal.
66pub mod wez;
67// MBA-1355: turret adjustment-unit conversions (SMOA/IPHY/clicks) and click-value parsing,
68// shared by the CLI and the WASM terminal. No feature gate: must compile for wasm32.
69pub mod adjustment;
70// MBA-1409: cleanroom `.drg` (Doppler drag-curve text file) parser, shared by the CLI and
71// the WASM terminal. No feature gate: must compile for wasm32; parses TEXT only (no
72// std::fs — file I/O stays in main.rs/wasm.rs).
73pub mod drag_file;
74pub mod trajectory_observation;
75#[cfg(target_arch = "wasm32")]
76pub mod wasm;
77#[cfg(test)]
78mod wasm_tests;
79// MBA-154: Make constants public for ballistics_rust wrapping
80pub mod atmosphere;
81pub mod constants;
82pub mod drag;
83pub mod wind;
84// MBA-153: Make wind_shear public for ballistics_rust wrapping
85pub mod wind_shear;
86// MBA-154: Make derivatives public for ballistics_rust wrapping
87pub mod derivatives;
88pub mod trajectory_sampling;
89// MBA-154: Make fast_trajectory public for ballistics_rust wrapping
90pub mod fast_trajectory;
91// MBA-155: Add advanced integration methods (RK4, RK45)
92pub mod trajectory_integration;
93// MBA-149 Phase 5 Priority 2: Export enhanced spin_drift
94pub mod pitch_damping;
95pub mod spin_decay;
96pub mod spin_drift;
97pub mod spin_drift_advanced;
98// MBA-149 Phase 5 Priority 2: Export enhanced precession_nutation
99pub mod precession_nutation;
100// MBA-153: Make aerodynamic_jump public for ballistics_rust wrapping
101pub mod aerodynamic_jump;
102// MBA-149 Phase 5 Priority 2: Export enhanced angle_calculations
103pub mod angle_calculations;
104pub mod transonic_drag;
105// MBA-153: Make reynolds public for ballistics_rust wrapping
106pub mod reynolds;
107// MBA-149 Phase 5 Priority 2: Export enhanced form_factor
108pub mod form_factor;
109// MBA-153: Make monte_carlo public for ballistics_rust wrapping
110pub mod bc_estimation;
111pub mod cluster_bc;
112pub mod monte_carlo;
113pub mod stability;
114pub mod stability_advanced;
115
116// Online mode: HTTP client for Flask API (feature-gated)
117#[cfg(feature = "online")]
118pub mod api_client;
119
120// BC5D table auto-download (feature-gated)
121#[cfg(feature = "online")]
122pub mod bc_table_download;
123
124// BC correction table for offline mode
125pub mod bc_table;
126
127// 5D BC correction tables (caliber-specific, ML-derived)
128pub mod bc_table_5d;
129
130// Import of third-party ballistic profile files (.a7p), feature-gated
131#[cfg(feature = "profile-import")]
132pub mod profile_import;
133
134// Internal type alias for compatibility
135pub(crate) type InternalBallisticInputs = BallisticInputs;
136
137// BC segment data for velocity-dependent BC
138#[derive(Debug, Clone)]
139pub struct BCSegmentData {
140    pub velocity_min: f64,
141    pub velocity_max: f64,
142    pub bc_value: f64,
143}