pub struct Environment { /* private fields */ }Expand description
Where and in what weather a rocket flies: a launch site, an atmosphere and a wind.
Environment::new puts the site on the WGS 84 ellipsoid, with the 1976 US Standard
Atmosphere and no wind. The with_ methods change the weather. For what this type doesn’t
offer, such as a geoid undulation, build an hpr_sim::Environment and wrap it with
Environment::from_sim.
use hpr::Environment;
// Spaceport America, 1,400 m up, with 5 m/s of wind from the west.
let environment = Environment::new(32.99, -106.97, 1400.0)?.with_constant_wind(5.0, 270.0)?;
assert_eq!(environment.sim().site().height_m, 1400.0);Implementations§
Source§impl Environment
impl Environment
Sourcepub fn new(
latitude_deg: f64,
longitude_deg: f64,
elevation_m: f64,
) -> Result<Self, Error>
pub fn new( latitude_deg: f64, longitude_deg: f64, elevation_m: f64, ) -> Result<Self, Error>
A launch site at latitude latitude_deg (degrees north), longitude longitude_deg
(degrees east) and elevation elevation_m, with the 1976 US Standard Atmosphere and no
wind.
The elevation is taken as both the site’s height above mean sea level, which the
atmosphere and wind are read at, and its height above the WGS 84 ellipsoid, which the
flight’s position is measured from, as if the geoid undulation, the gap between the two,
were zero; hpr has no geoid model. The air is read where you said; the site’s gravity is
off by the free-air gradient, about 3.1 µm/s² per meter of undulation. To give an
undulation N, build an hpr_sim::Environment on the site’s ellipsoidal height
h = H + N, set N with hpr_sim::Environment::with_geoid_undulation_m, and wrap it
with Environment::from_sim; the air is then read at H. Heights in a flight’s results
are above the site. Longitude is positive east, so a site in the Americas has a negative
one.
§Errors
Error::Core for a latitude outside [−90°, 90°] or a value that isn’t finite.
Sourcepub fn with_constant_wind(
self,
speed_m_s: f64,
from_deg: f64,
) -> Result<Self, Error>
pub fn with_constant_wind( self, speed_m_s: f64, from_deg: f64, ) -> Result<Self, Error>
The same place and atmosphere, with a wind of speed_m_s at every height, blowing from
from_deg: the direction it comes from, clockwise from true north (270° is a west wind).
§Errors
Error::Domain for a direction that isn’t finite; Error::Atmos for a negative or
non-finite speed.
Sourcepub fn with_atmosphere(self, atmosphere: impl Atmosphere + 'static) -> Self
pub fn with_atmosphere(self, atmosphere: impl Atmosphere + 'static) -> Self
The same place and wind, with atmosphere in place of the standard one: any
Atmosphere, such as a balloon sounding’s levels (hpr_atmos::SoundingProfile), or a
model of your own.
Sourcepub fn with_gravity(self, gravity: GravityModel) -> Result<Self, Error>
pub fn with_gravity(self, gravity: GravityModel) -> Result<Self, Error>
The same place and weather, with gravity evaluated by gravity in place of the default,
GravityModel::Ellipsoidal: the full normal gravity vector at the rocket’s position.
GravityModel::VerticalTaylor is RocketPy’s formula, for like-for-like comparisons with
it; GravityModel has the rest. The Earth’s rotation is kept.
use hpr::Environment;
use hpr::hpr_core::earth::GravityModel;
let environment =
Environment::new(32.99, -106.97, 1400.0)?.with_gravity(GravityModel::VerticalTaylor)?;
assert_eq!(environment.sim().earth.gravity_model(), GravityModel::VerticalTaylor);§Errors
Error::Core for a constant gravity that is negative or not finite.
Sourcepub fn from_sim(sim: Environment) -> Self
pub fn from_sim(sim: Environment) -> Self
An environment built with hpr_sim directly.
Sourcepub fn sim(&self) -> &Environment
pub fn sim(&self) -> &Environment
The hpr_sim::Environment this wraps.
Trait Implementations§
Source§impl Clone for Environment
impl Clone for Environment
Source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Environment
impl !UnwindSafe for Environment
impl Freeze for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnsafeUnpin for Environment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more