Skip to main content

Environment

Struct Environment 

Source
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

Source

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.

Source

pub fn with_wind(self, wind: impl Wind + 'static) -> Self

The same place and atmosphere, with wind in place of the wind: any Wind, such as hpr_atmos’s power law, log law or layers by height, or a model of your own.

Source

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.

Source

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.

Source

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.

Source

pub fn from_sim(sim: Environment) -> Self

An environment built with hpr_sim directly.

Source

pub fn sim(&self) -> &Environment

The hpr_sim::Environment this wraps.

Trait Implementations§

Source§

impl Clone for Environment

Source§

fn clone(&self) -> Environment

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
Source§

impl Debug for Environment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.