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