Expand description
FFI bindings for iOS/Swift integration
Structs§
- FFIAtmospheric
Conditions - FFIBallistic
Inputs - FFIMonte
Carlo Params - FFIMonte
Carlo Results - FFIReticle
Hold - Where a firing solution lands in a reticle (MBA-1361).
- FFITrajectory
Point - FFITrajectory
Result - FFITrajectory
Sample - FFIWind
Conditions
Constants§
- FFI_
BC_ REFERENCE_ ARMY_ STANDARD_ METRO - FFI_
BC_ REFERENCE_ ICAO - Which standard atmosphere a
bcvalue passed toballistics_bc_for_reference_standardis 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 as0(ICAO), matching the permissive unrecognized-value conventionconvert_inputsalready uses forbc_type. - FFI_
NO_ EXPLICIT_ TEMPERATURE - Sentinel
explicit_temperature_cvalue meaning “no explicit temperature override” for theballistics_density_altitude_*exports below (MBA-1366) — same NaN-means-absent conventionFFIBallisticInputs::latitudealready uses. Any NaN bit pattern is accepted (checked viais_nan(), not equality), matching that precedent. - FFI_
RETICLE_ ERR_ INVALID_ ARGUMENT - A null pointer, or a
marks_lenoutside1..=MAX_FFI_RETICLE_MARKS. - FFI_
RETICLE_ ERR_ MAGNIFICATION magnificationwas 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_planevalue selecting a FIRST-focal-plane reticle (subtensions constant across magnification). Any value other thanFFI_RETICLE_SECOND_FOCAL_PLANEis treated as FFP.- FFI_
RETICLE_ OK ballistics_hold_point_in_reticlesucceeded andoutwas written.- FFI_
RETICLE_ SECOND_ FOCAL_ PLANE focal_planevalue selecting a SECOND-focal-plane reticle (subtensions scale asreference_magnification / magnification).- MAX_
FFI_ DRAG_ TABLE_ LEN - Maximum C-ABI custom drag-table row count.
- MAX_
FFI_ RETICLE_ MARKS - Largest
marks_lenballistics_hold_point_in_reticlewill 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_standardto the ICAO-referenced value everyFFIBallisticInputs.bc_valuein this module expects (MBA-1365). - ballistics_
calculate_ ⚠trajectory - Calculate a trajectory through the C ABI.
- ballistics_
calculate_ ⚠trajectory_ with_ drag_ table ballistics_calculate_trajectorywith 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_valueare ignored, and the retardation denominator becomes the projectile’s sectional density (mass and diameter ininputsmust therefore be positive). Mach values must be strictly ascending withdrag_table_lenin[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_tablewith an additional whole-curve drag scale (MBA-1356): the deck’s interpolated Cd is multiplied bycd_scaleat the same site the base export uses, i.e.Cd_used = table.interpolate(mach) * cd_scale.cd_scale = 1.0is neutral and produces byte-identical output toballistics_calculate_trajectory_with_drag_tableon 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_anglewith 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_valueare ignored, and the retardation denominator becomes the projectile’s sectional density (mass and diameter ininputsmust therefore be positive). Mach values must be strictly ascending withdrag_table_lenin[2, MAX_FFI_DRAG_TABLE_LEN]and finite positive Cd; outside the deck’s Mach domain the nearest endpoint Cd is held. Pair this withballistics_calculate_trajectory_with_drag_tableusing 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_tablewith an additional whole-curve drag scale (MBA-1356): the deck’s interpolated Cd is multiplied bycd_scaleat the same site the base export uses, i.e.Cd_used = table.interpolate(mach) * cd_scale.cd_scale = 1.0is neutral and produces byte-identical output toballistics_calculate_zero_angle_with_drag_tableon the same deck. Pair this withballistics_calculate_trajectory_with_drag_table_scaledusing the same deck AND the samecd_scaleto 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 todensity_altitude_m— it only is whenexplicit_temperature_cisFFI_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_mimplies (MBA-1366; seecrate::atmosphere::resolve_atmosphere_for_density_altitudefor 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; seecrate::atmosphere::reduce_qnh_to_station_pressurefor the formula).FFIAtmosphericConditions.pressurehas always meant absolute station pressure, and remains a frozenrepr(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 asballistics_bc_for_reference_standard: call it once on a caller-declared QNH reading before writing the result intoFFIAtmosphericConditions.pressure, then use every existingballistics_calculate_trajectory*/ballistics_calculate_zero_angle*/ballistics_monte_carlo*export completely unchanged — every one of them readspressureas 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.