Environment

Struct Environment 

Source
pub struct Environment {
    pub shape: EarthShape,
    pub atmosphere: Atmosphere,
    pub wavelength: f64,
}
Expand description

Structure storing the shape of the underlying world and the atmospheric model.

Fields§

§shape: EarthShape§atmosphere: Atmosphere§wavelength: f64

Implementations§

Source§

impl Environment

Source

pub fn n(&self, h: f64) -> f64

Returns the refractive index of the air at the given altitude.

Source

pub fn dn(&self, h: f64) -> f64

Returns the derivative of the refractive index of the air with respect to the altitude, at the given altitude

Source

pub fn radius(&self) -> Option<f64>

Returns Some(radius in meters) if the planet model is spherical, or None if it’s flat.

Source

pub fn cast_ray<'a>( &'a self, start_h: f64, start_ang: f64, straight: bool, ) -> Box<dyn Path<'a> + 'a>

Returns an object representing a light path.

The path is defined by 3 parameters:

  • start_h - the starting altitude of the path in meters
  • start_ang - the initial angle in radians between the path and the horizontal plane; -π/2 is down, 0 is horizontal, π/2 is up
  • straight - true if the path should be a straight line, false if it should be a ray affected by the atmosphere
Source

pub fn cast_ray_stepper<'a>( &'a self, start_h: f64, start_ang: f64, straight: bool, ) -> Box<dyn PathStepper<Item = RayState> + 'a>

Returns an object representing a light path.

The path is defined by 3 parameters:

  • start_h - the starting altitude of the path in meters
  • start_ang - the initial angle in radians between the path and the horizontal plane; -π/2 is down, 0 is horizontal, π/2 is up
  • straight - true if the path should be a straight line, false if it should be a ray affected by the atmosphere
Source

pub fn cast_ray_target<'a>( &'a self, start_h: f64, tgt_h: f64, tgt_dist: f64, straight: bool, ) -> Box<dyn Path<'a> + 'a>

Returns an object representing a light path.

Instead of using the initial angle, this method chooses a ray that will hit a given target. The target is defined as distance and altitude.

  • start_h - the initial altitude of the path in meters
  • tgt_h - the altitude of the target point in meters
  • tgt_dist - the distance of the target point from the initial point, in meters
  • straight - true if the path should be a straight line, false if it should be a ray affected by the atmosphere

The ray is calculated by performing a binary search on the initial angle.

Trait Implementations§

Source§

impl Clone for Environment

Source§

fn clone(&self) -> Environment

Returns a duplicate of the value. Read more
1.0.0 · 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> 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.