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, run_monte_carlo, run_monte_carlo_with_direction_std_dev,
21    run_monte_carlo_with_wind, run_monte_carlo_with_wind_and_direction_std_dev,
22    run_monte_carlo_with_wind_and_direction_std_dev_seeded, AtmosphericConditions,
23    BallisticInputs, BallisticsError, BcEstimate, BcFitMode, MonteCarloParams,
24    MonteCarloResults, TrajectoryPoint, TrajectoryResult, TrajectorySolver, WindConditions,
25    DEFAULT_HIT_RADIUS_M, MAX_TRAJECTORY_POINTS, TARGET_NOT_REACHED_SENTINEL_M,
26};
27pub use atmosphere::{AtmoSegment, AtmoSock};
28pub use drag_model::DragModel;
29pub use moving_target::{
30    calculate_lead, lead_from_tof, mover_ring, LeadComponents, LeadError, LeadSolution,
31};
32pub use solve_json::{
33    decode_solve_request_v1, ResolvedSolveRequestV1, SolveErrorCodeV1, SolveErrorEnvelopeV1,
34    SolveRequestV1, SolveSuccessV1, MAX_SOLVE_JSON_SAMPLES_V1, SOLVE_JSON_SCHEMA_VERSION_V1,
35};
36pub use solve_v1::solve_v1;
37pub use trajectory_observation::{
38    TrajectoryObservation, TrajectoryObservationError, TrajectoryObservationFlag,
39    TrajectoryTermination,
40};
41pub use trajectory_sampling::MAX_TRAJECTORY_SAMPLES;
42
43// Module declarations
44pub mod cli_api;
45pub mod moving_target;
46mod drag_model;
47// The C ABI. Gated behind the default-on `ffi` feature so a binary that links two versions of
48// this crate can disable it on one edge and avoid duplicate #[no_mangle] symbols.
49#[cfg(feature = "ffi")]
50pub mod ffi;
51pub mod solve_json;
52pub mod solve_v1;
53pub mod trajectory_observation;
54#[cfg(target_arch = "wasm32")]
55pub mod wasm;
56#[cfg(test)]
57mod wasm_tests;
58// MBA-154: Make constants public for ballistics_rust wrapping
59pub mod atmosphere;
60pub mod constants;
61pub mod drag;
62mod drag_tables;
63pub mod wind;
64// MBA-153: Make wind_shear public for ballistics_rust wrapping
65pub mod wind_shear;
66// MBA-154: Make derivatives public for ballistics_rust wrapping
67pub mod derivatives;
68pub mod trajectory_sampling;
69// MBA-154: Make fast_trajectory public for ballistics_rust wrapping
70pub mod fast_trajectory;
71// MBA-155: Add advanced integration methods (RK4, RK45)
72pub mod trajectory_integration;
73// MBA-149 Phase 5 Priority 2: Export enhanced spin_drift
74pub mod pitch_damping;
75pub mod spin_decay;
76pub mod spin_drift;
77pub mod spin_drift_advanced;
78// MBA-149 Phase 5 Priority 2: Export enhanced precession_nutation
79pub mod precession_nutation;
80// MBA-153: Make aerodynamic_jump public for ballistics_rust wrapping
81pub mod aerodynamic_jump;
82// MBA-149 Phase 5 Priority 2: Export enhanced angle_calculations
83pub mod angle_calculations;
84pub mod transonic_drag;
85// MBA-153: Make reynolds public for ballistics_rust wrapping
86pub mod reynolds;
87// MBA-149 Phase 5 Priority 2: Export enhanced form_factor
88pub mod form_factor;
89// MBA-153: Make monte_carlo public for ballistics_rust wrapping
90pub mod bc_estimation;
91pub mod cluster_bc;
92pub mod monte_carlo;
93pub mod stability;
94pub mod stability_advanced;
95
96// Online mode: HTTP client for Flask API (feature-gated)
97#[cfg(feature = "online")]
98pub mod api_client;
99
100// BC5D table auto-download (feature-gated)
101#[cfg(feature = "online")]
102pub mod bc_table_download;
103
104// BC correction table for offline mode
105pub mod bc_table;
106
107// 5D BC correction tables (caliber-specific, ML-derived)
108pub mod bc_table_5d;
109
110// Import of third-party ballistic profile files (.a7p), feature-gated
111#[cfg(feature = "profile-import")]
112pub mod profile_import;
113
114// Internal type alias for compatibility
115pub(crate) type InternalBallisticInputs = BallisticInputs;
116
117// BC segment data for velocity-dependent BC
118#[derive(Debug, Clone)]
119pub struct BCSegmentData {
120    pub velocity_min: f64,
121    pub velocity_max: f64,
122    pub bc_value: f64,
123}