Skip to main content

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-1343 Phase B: WEZ (`monte-carlo --wez`) sweep core, shared by the CLI and the WASM terminal.
62pub mod wez;
63pub mod trajectory_observation;
64#[cfg(target_arch = "wasm32")]
65pub mod wasm;
66#[cfg(test)]
67mod wasm_tests;
68// MBA-154: Make constants public for ballistics_rust wrapping
69pub mod atmosphere;
70pub mod constants;
71pub mod drag;
72mod drag_tables;
73pub mod wind;
74// MBA-153: Make wind_shear public for ballistics_rust wrapping
75pub mod wind_shear;
76// MBA-154: Make derivatives public for ballistics_rust wrapping
77pub mod derivatives;
78pub mod trajectory_sampling;
79// MBA-154: Make fast_trajectory public for ballistics_rust wrapping
80pub mod fast_trajectory;
81// MBA-155: Add advanced integration methods (RK4, RK45)
82pub mod trajectory_integration;
83// MBA-149 Phase 5 Priority 2: Export enhanced spin_drift
84pub mod pitch_damping;
85pub mod spin_decay;
86pub mod spin_drift;
87pub mod spin_drift_advanced;
88// MBA-149 Phase 5 Priority 2: Export enhanced precession_nutation
89pub mod precession_nutation;
90// MBA-153: Make aerodynamic_jump public for ballistics_rust wrapping
91pub mod aerodynamic_jump;
92// MBA-149 Phase 5 Priority 2: Export enhanced angle_calculations
93pub mod angle_calculations;
94pub mod transonic_drag;
95// MBA-153: Make reynolds public for ballistics_rust wrapping
96pub mod reynolds;
97// MBA-149 Phase 5 Priority 2: Export enhanced form_factor
98pub mod form_factor;
99// MBA-153: Make monte_carlo public for ballistics_rust wrapping
100pub mod bc_estimation;
101pub mod cluster_bc;
102pub mod monte_carlo;
103pub mod stability;
104pub mod stability_advanced;
105
106// Online mode: HTTP client for Flask API (feature-gated)
107#[cfg(feature = "online")]
108pub mod api_client;
109
110// BC5D table auto-download (feature-gated)
111#[cfg(feature = "online")]
112pub mod bc_table_download;
113
114// BC correction table for offline mode
115pub mod bc_table;
116
117// 5D BC correction tables (caliber-specific, ML-derived)
118pub mod bc_table_5d;
119
120// Import of third-party ballistic profile files (.a7p), feature-gated
121#[cfg(feature = "profile-import")]
122pub mod profile_import;
123
124// Internal type alias for compatibility
125pub(crate) type InternalBallisticInputs = BallisticInputs;
126
127// BC segment data for velocity-dependent BC
128#[derive(Debug, Clone)]
129pub struct BCSegmentData {
130    pub velocity_min: f64,
131    pub velocity_max: f64,
132    pub bc_value: f64,
133}