[][src]Struct holding_solar::Orbit

pub struct Orbit {
    pub parent: PlanetId,
    pub body: PlanetId,
    pub shift: usize,
    pub eccentricity: f32,
    pub period: usize,
}

Describes the orbit of a given planet.

For the sake of simplicity, orbits are rounded to the nearest day relative to the parent object. This makes calendar calculation much much simpler, as you do not need to manage leap seconds / days.

Fields

parent: PlanetId

The id of the parent planet.

body: PlanetId

The body that is orbiting.

shift: usize

The starting offset for the orbit in days.

eccentricity: f32

The eccentricity of the orbit, or how elliptic it is.

period: usize

The amount of time a single orbit takes in seconds.

For simplicity, valid planets must have a period that is a multiple of the number of seconds in a day.

Implementations

impl Orbit[src]

pub fn from_period(
    target: &CelestialBody,
    parent: PlanetId,
    period: usize,
    shift: usize
) -> Self
[src]

Create a new orbit with a given perion.

pub fn from_radius(
    target: &CelestialBody,
    parent: PlanetId,
    semimajor_axis: f32,
    shift: usize
) -> Self
[src]

Creates a new orbit at a given semimajor axis. Note that for now, since the period is a fixed number of days relative to the parent, this will be rounded. This is for simpler interop with the calendar. Nobody wants to RP leap seconds!

pub fn get_phase(
    &self,
    lookup: &dyn PlanetStore,
    date_time: CalendarDateTime<'_>
) -> Option<Phase>
[src]

Get the phase of the orbit.

Only valid if the body being orbited is in turn orbiting something else (that gives off light).

pub fn get_orbit_radians(&self, seconds: u32) -> f32[src]

Given some day, gets the radians relative to the periapsis.

pub fn get_distance(&self, seconds: u32) -> f32[src]

Calculates the distance between a body and its parent.

pub fn get_semimajor_axis(&self) -> f32[src]

Gets the semimajor axis

pub fn validate_calendar(
    &self,
    calendar: &Calendar
) -> Result<bool, OrbitValidationError>
[src]

Validates an orbit against a calendar, ensuring the period is correct.

Trait Implementations

impl Clone for Orbit[src]

impl Copy for Orbit[src]

impl Debug for Orbit[src]

impl<'de> Deserialize<'de> for Orbit[src]

impl Serialize for Orbit[src]

Auto Trait Implementations

impl RefUnwindSafe for Orbit

impl Send for Orbit

impl Sync for Orbit

impl Unpin for Orbit

impl UnwindSafe for Orbit

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,