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