Skip to main content

Module ffi

Module ffi 

Source
Expand description

FFI bindings for iOS/Swift integration

Structs§

FFIAtmosphericConditions
FFIBallisticInputs
FFIMonteCarloParams
FFIMonteCarloResults
FFIReticleHold
Where a firing solution lands in a reticle (MBA-1361).
FFITrajectoryPoint
FFITrajectoryResult
FFITrajectorySample
FFIWindConditions

Constants§

FFI_BC_REFERENCE_ARMY_STANDARD_METRO
FFI_BC_REFERENCE_ICAO
Which standard atmosphere a bc value passed to ballistics_bc_for_reference_standard is referenced to (MBA-1365). 0 = ICAO (the default every other export in this module assumes), 1 = Army Standard Metro (some vendor-published BCs, notably many Sierra/Hornady/Barnes bullets). Any other value is treated as 0 (ICAO), matching the permissive unrecognized-value convention convert_inputs already uses for bc_type.
FFI_NO_EXPLICIT_TEMPERATURE
Sentinel explicit_temperature_c value meaning “no explicit temperature override” for the ballistics_density_altitude_* exports below (MBA-1366) — same NaN-means-absent convention FFIBallisticInputs::latitude already uses. Any NaN bit pattern is accepted (checked via is_nan(), not equality), matching that precedent.
FFI_RETICLE_ERR_INVALID_ARGUMENT
A null pointer, or a marks_len outside 1..=MAX_FFI_RETICLE_MARKS.
FFI_RETICLE_ERR_MAGNIFICATION
magnification was not finite and greater than zero.
FFI_RETICLE_ERR_NON_FINITE
A mark coordinate, or the supplied firing solution, was not finite.
FFI_RETICLE_ERR_REFERENCE_MAGNIFICATION
A second-focal-plane call carried a non-finite or non-positive reference_magnification.
FFI_RETICLE_FIRST_FOCAL_PLANE
focal_plane value selecting a FIRST-focal-plane reticle (subtensions constant across magnification). Any value other than FFI_RETICLE_SECOND_FOCAL_PLANE is treated as FFP.
FFI_RETICLE_OK
ballistics_hold_point_in_reticle succeeded and out was written.
FFI_RETICLE_SECOND_FOCAL_PLANE
focal_plane value selecting a SECOND-focal-plane reticle (subtensions scale as reference_magnification / magnification).
MAX_FFI_DRAG_TABLE_LEN
Maximum C-ABI custom drag-table row count.
MAX_FFI_RETICLE_MARKS
Largest marks_len ballistics_hold_point_in_reticle will accept (MBA-1361).
MIN_FFI_STEP_SIZE_MS
Minimum C-ABI trajectory step_size, in milliseconds (0.1 ms = 0.0001 s).

Functions§

ballistics_bc_for_reference_standard
Convert a ballistic coefficient declared under reference_standard to the ICAO-referenced value every FFIBallisticInputs.bc_value in this module expects (MBA-1365).
ballistics_calculate_trajectory
Calculate a trajectory through the C ABI.
ballistics_calculate_trajectory_with_drag_table
ballistics_calculate_trajectory with a caller-supplied custom drag deck (Cd vs Mach, e.g. Hornady CDM / Doppler-radar data). The deck REPLACES the G-model + BC for drag: bc_type/bc_value are ignored, and the retardation denominator becomes the projectile’s sectional density (mass and diameter in inputs must therefore be positive). Mach values must be strictly ascending with drag_table_len in [2, MAX_FFI_DRAG_TABLE_LEN] and finite positive Cd; outside the deck’s Mach domain the nearest endpoint Cd is held.
ballistics_calculate_trajectory_with_drag_table_scaled
ballistics_calculate_trajectory_with_drag_table with an additional whole-curve drag scale (MBA-1356): the deck’s interpolated Cd is multiplied by cd_scale at the same site the base export uses, i.e. Cd_used = table.interpolate(mach) * cd_scale. cd_scale = 1.0 is neutral and produces byte-identical output to ballistics_calculate_trajectory_with_drag_table on the same deck. Typical truing values are in [0.90, 1.10]; values outside that band are accepted here (the engine only rejects non-finite or non-positive) — an “unusually large” warning is a CLI-only concern (Task 2), not part of this frozen C ABI.
ballistics_calculate_zero_angle
Calculate the zero angle for a target distance through the C ABI.
ballistics_calculate_zero_angle_with_drag_table
ballistics_calculate_zero_angle with a caller-supplied custom drag deck (Cd vs Mach, e.g. Hornady CDM / Doppler-radar data). The deck REPLACES the G-model + BC for drag: bc_type/bc_value are ignored, and the retardation denominator becomes the projectile’s sectional density (mass and diameter in inputs must therefore be positive). Mach values must be strictly ascending with drag_table_len in [2, MAX_FFI_DRAG_TABLE_LEN] and finite positive Cd; outside the deck’s Mach domain the nearest endpoint Cd is held. Pair this with ballistics_calculate_trajectory_with_drag_table using the same deck to fly the solved angle — the two exports share identical deck semantics.
ballistics_calculate_zero_angle_with_drag_table_scaled
ballistics_calculate_zero_angle_with_drag_table with an additional whole-curve drag scale (MBA-1356): the deck’s interpolated Cd is multiplied by cd_scale at the same site the base export uses, i.e. Cd_used = table.interpolate(mach) * cd_scale. cd_scale = 1.0 is neutral and produces byte-identical output to ballistics_calculate_zero_angle_with_drag_table on the same deck. Pair this with ballistics_calculate_trajectory_with_drag_table_scaled using the same deck AND the same cd_scale to fly the solved angle. Typical truing values are in [0.90, 1.10]; values outside that band are accepted here (the engine only rejects non-finite or non-positive) — an “unusually large” warning is a CLI-only concern (Task 2).
ballistics_density_altitude_altitude_m
Companion to ballistics_density_altitude_temperature_c: the back-solved station ALTITUDE (meters, geometric) for the same (density_altitude_m, explicit_temperature_c) pair. This is NOT necessarily equal to density_altitude_m — it only is when explicit_temperature_c is FFI_NO_EXPLICIT_TEMPERATURE (see the Rust doc comment’s algebraic identity).
ballistics_density_altitude_pressure_hpa
Companion to ballistics_density_altitude_temperature_c: the back-solved station PRESSURE (hPa) for the same (density_altitude_m, explicit_temperature_c) pair.
ballistics_density_altitude_temperature_c
Back-solve the station TEMPERATURE (Celsius) an ISA-equivalent atmosphere at density_altitude_m implies (MBA-1366; see crate::atmosphere::resolve_atmosphere_for_density_altitude for the full derivation).
ballistics_free_monte_carlo_results
Release Monte Carlo results allocated by either Monte Carlo C entry point.
ballistics_free_trajectory_result
Release a trajectory result allocated by ballistics_calculate_trajectory.
ballistics_get_version
ballistics_hold_point_in_reticle
Place an angular firing solution in a reticle (MBA-1361).
ballistics_monte_carlo
Run a Monte Carlo simulation through the C ABI.
ballistics_monte_carlo_with_direction_std_dev
Run a Monte Carlo simulation with independent wind-direction uncertainty through the C ABI.
ballistics_quick_trajectory
ballistics_reduce_qnh_pressure
Reduce a sea-level-corrected altimeter setting (QNH, in hPa) to the station pressure at altitude_m (MBA-1397; see crate::atmosphere::reduce_qnh_to_station_pressure for the formula). FFIAtmosphericConditions.pressure has always meant absolute station pressure, and remains a frozen repr(C) struct enforced by an ABI regression test with no room to add a pressure-reference-mode field, so this is a standalone pure conversion instead of a struct setter — exactly the same pattern as ballistics_bc_for_reference_standard: call it once on a caller-declared QNH reading before writing the result into FFIAtmosphericConditions.pressure, then use every existing ballistics_calculate_trajectory*/ballistics_calculate_zero_angle*/ballistics_monte_carlo* export completely unchanged — every one of them reads pressure as absolute station pressure already, so feeding it an already-reduced value is a pure addition to the ABI, not a modification. No existing caller that never calls this function is affected, and no recompile is required for callers that don’t opt into QNH support.