Skip to main content

TrajectorySolver

Struct TrajectorySolver 

Source
pub struct TrajectorySolver { /* private fields */ }

Implementations§

Source§

impl TrajectorySolver

Source

pub fn new( inputs: BallisticInputs, wind: WindConditions, atmosphere: AtmosphericConditions, ) -> Self

Source

pub fn new_with_resolved_station_atmosphere( inputs: BallisticInputs, wind: WindConditions, atmosphere: AtmosphericConditions, ) -> Self

Construct a solver from station temperature and pressure that a presence-aware service has already resolved. Unlike Self::new, exact sea-level standard values remain authoritative at nonzero altitude rather than acting as legacy omission sentinels.

pub (MBA-1397; was pub(crate)): a QNH-aware caller (native CLI, WASM) that has already reduced a declared altimeter setting to station pressure via crate::atmosphere::resolve_station_conditions_with_pressure_mode needs this constructor too, and those callers live in a different crate (src/main.rs is a separate binary crate over the library). Widening visibility only, no signature change: every existing pub(crate) caller is unaffected.

Source

pub fn set_max_range(&mut self, range: f64)

Source

pub fn set_time_step(&mut self, step: f64)

Source

pub fn set_wind_segments(&mut self, segments: Vec<WindSegment>)

Supply downrange-segmented wind. Each segment is (speed_kmh, angle_deg, until_distance_m); the wind for a given downrange distance is the first segment whose until_distance_m exceeds it (a step function), and wind is zero beyond the last segment. An empty list clears segmented wind (reverts to the scalar wind). The angle convention matches WindConditions (0 = headwind, 90 = from the right).

Source

pub fn set_atmo_segments(&mut self, segments: Vec<AtmoSegment>)

Supply downrange-segmented atmosphere (MBA-1137). Each segment is (temp_c, pressure_hpa, humidity_percent, until_distance_m), defined at the shooter base altitude; the per-substep local-atmosphere recompute selects the active zone by downrange distance (first zone whose until_distance_m exceeds it; the last zone is held beyond the final threshold). The zone’s base conditions are composed with the vertical altitude lapse via get_local_atmosphere_humid, so a steeply-arcing shot still sees the y-lapse on top of the zone base. An empty list clears segmented atmosphere (reverts to the resolved single-station conditions).

Source

pub fn solve(&self) -> Result<TrajectoryResult, BallisticsError>

Source

pub fn effective_drag_coefficient( &self, velocity_magnitude: f64, speed_of_sound: f64, ) -> Option<f64>

The projectile’s own drag coefficient at one speed — the curve a shooter would compare against a measured CDM trace, not the reference-table Cd (MBA-1423).

A G-model Cd describes the standard projectile, so reporting it directly would hand a consumer the same G7 curve no matter which bullet was flown. Scaling by the form factor SD / BC converts it to this projectile’s actual Cd, from the identity that both descriptions must produce the same retardation:

Cd_own / SD == Cd_ref / BC   =>   Cd_own == Cd_ref * SD / BC

Because the denominator comes from the same internal resolver the integrator divides by, a velocity- or Mach-segmented BC carries into the result and its band steps appear in the reported curve. The same expression is already correct for a custom drag table, where the denominator is the sectional density and the scale factor collapses to 1.

Returns None when the projectile’s mass or diameter is unavailable, since sectional density — and therefore the projectile’s own Cd — is undefined without both.

Trait Implementations§

Source§

impl Clone for TrajectorySolver

Source§

fn clone(&self) -> TrajectorySolver

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.