compute_wez

Function compute_wez 

Source
pub fn compute_wez(
    velocity: f64,
    angle: f64,
    bc: f64,
    mass: f64,
    diameter: f64,
    num_sims: usize,
    velocity_std: f64,
    angle_std: f64,
    bc_std: f64,
    wind_std: f64,
    wind_direction_std: f64,
    wind_speed: f64,
    wind_direction: f64,
    wind_vertical: f64,
    wind_call_error: f64,
    target_size: TargetSizeMetric,
    wez_start: f64,
    wez_end: f64,
    wez_step: f64,
    drag_model: DragModel,
    custom_drag_table: Option<DragTable>,
    cd_scale: f64,
    cant: f64,
) -> Result<WezResult, Box<dyn Error>>
Expand description

Run a WEZ sweep and return its per-range rows plus the sweep-level parameters as a WezResult, leaving all rendering (summary table / statistics CSV / full JSON) to the caller. All inputs are metric (the CLI converts from user units before calling).

§Parameters

NOTE the angle-like parameters (angle, cant, wind_direction, angle_std, wind_direction_std) are in DEGREES — this function converts to radians itself, unlike BallisticInputs/WindConditions elsewhere in the crate, which carry radians. This mirrors the CLI flag set the sweep was extracted from (MBA-1317).

  • velocity — muzzle velocity, m/s.
  • angle — launch (elevation) angle held for every sweep step, DEGREES.
  • bc — ballistic coefficient (dimensionless; referenced to drag_model).
  • mass — bullet mass, kg.
  • diameter — bullet diameter, m.
  • num_sims — Monte Carlo samples per range step.
  • velocity_std — muzzle-velocity standard deviation, m/s.
  • angle_std — elevation-angle standard deviation, DEGREES (the derived azimuth dispersion is half of it, matching the base Monte Carlo command).
  • bc_std — BC standard deviation (dimensionless).
  • wind_std — ballistic (gust-to-gust) wind-speed standard deviation, m/s.
  • wind_direction_std — wind-direction standard deviation, DEGREES.
  • wind_speed — base wind speed, m/s.
  • wind_direction — base wind direction, DEGREES (wind-FROM: 0 = headwind, 90 = from the right).
  • wind_vertical — base vertical wind, m/s, positive = updraft.
  • wind_call_error — the shooter’s wind-CALL error, m/s; composed with wind_std in quadrature (see WezResult::combined_wind_speed_std_mps).
  • target_size — the target box/radius, already in meters (TargetSize::to_metric).
  • wez_start / wez_end / wez_step — sweep bounds and step, meters (wez_end inclusive).
  • drag_model — the G-model bc is referenced to (DragModel::G1 / DragModel::G7); ignored for drag whenever custom_drag_table is set.
  • custom_drag_table — optional Mach-keyed Cd deck replacing the G-model + BC drag entirely.
  • cd_scale — whole-curve multiplier on custom_drag_table’s interpolated Cd (MBA-1356); 1.0 = neutral. Inert when custom_drag_table is None.
  • cant — rifle cant, DEGREES, positive = clockwise from the shooter.

A fixed, distinct seed per range step (0x57_45_5A_00 ^ step_index) keeps a sweep reproducible run-to-run while still drawing independent samples at each range.