Enum cdshealpix::compass_point::MainWind

source ·
pub enum MainWind {
    S,
    SE,
    E,
    SW,
    C,
    NE,
    W,
    NW,
    N,
}
Expand description

Main winds directions

Variants§

§

S

South

§

SE

Southeast

§

E

East

§

SW

Southwest

§

C

Center (not a real main winds)

§

NE

Northeast

§

W

West

§

NW

Norhtwest

§

N

North

Implementations§

source§

impl MainWind

source

pub fn from_index(i: u8) -> MainWind

Returns a Main wind direction give an index. We define this method for calls from external languages

  • 0 => S
  • 1 => SE
  • 2 => E
  • 3 => SW
  • 4 => C
  • 5 => NE
  • 6 => W
  • 7 => NW
  • 8 => N
§Input
  • i index in [0, 8]
§Output
  • main wind direction
§Panics

If the given index in not in [0, 8]

§Example
use cdshealpix::compass_point::{MainWind};

assert_eq!(MainWind::from_index(0), MainWind::S);
assert_eq!(MainWind::from_index(1), MainWind::SE);
assert_eq!(MainWind::from_index(2), MainWind::E);
assert_eq!(MainWind::from_index(3), MainWind::SW);
assert_eq!(MainWind::from_index(4), MainWind::C);
assert_eq!(MainWind::from_index(5), MainWind::NE);
assert_eq!(MainWind::from_index(6), MainWind::W);
assert_eq!(MainWind::from_index(7), MainWind::NW);
assert_eq!(MainWind::from_index(8), MainWind::N);
source

pub fn is_cardinal(&self) -> bool

Returns true is the Main Wind is more particularly a Cardinal point.

use cdshealpix::compass_point::{MainWind};

assert_eq!(true, MainWind::S.is_cardinal());
assert_eq!(true, MainWind::E.is_cardinal());
assert_eq!(true, MainWind::N.is_cardinal());
assert_eq!(true, MainWind::W.is_cardinal());
assert_eq!(false, MainWind::C.is_cardinal());
assert_eq!(false, MainWind::SE.is_cardinal());
assert_eq!(false, MainWind::SW.is_cardinal());
assert_eq!(false, MainWind::NE.is_cardinal());
assert_eq!(false, MainWind::NW.is_cardinal());
source

pub fn to_cardinal(&self) -> Cardinal

Convert this main wind into a Cardinal point.

§Panics

If the maind wind is not a cardinal point

source

pub fn is_ordinal(&self) -> bool

Returns true is the Main Wind is more particularly an Ordinal point.

use cdshealpix::compass_point::{MainWind};

assert_eq!(false, MainWind::S.is_ordinal());
assert_eq!(false, MainWind::E.is_ordinal());
assert_eq!(false, MainWind::N.is_ordinal());
assert_eq!(false, MainWind::W.is_ordinal());
assert_eq!(false, MainWind::C.is_ordinal());
assert_eq!(true, MainWind::SE.is_ordinal());
assert_eq!(true, MainWind::SW.is_ordinal());
assert_eq!(true, MainWind::NE.is_ordinal());
assert_eq!(true, MainWind::NW.is_ordinal());
source

pub fn to_ordinal(&self) -> Ordinal

Convert this main wind into an Ordinal point.

§Panics

If the maind wind is not an orinal point

source

pub fn opposite(&self) -> MainWind

Returns the given main wind opposite direction.

§Example
use cdshealpix::compass_point::{MainWind};

assert_eq!(MainWind::S.opposite(),  MainWind::N);
assert_eq!(MainWind::SE.opposite(), MainWind::NW);
assert_eq!(MainWind::E.opposite(),  MainWind::W);
assert_eq!(MainWind::SW.opposite(), MainWind::NE);
assert_eq!(MainWind::C.opposite(),  MainWind::C);
assert_eq!(MainWind::NE.opposite(), MainWind::SW);
assert_eq!(MainWind::W.opposite(),  MainWind::E);
assert_eq!(MainWind::NW.opposite(), MainWind::SE);
assert_eq!(MainWind::N.opposite(),  MainWind::S);
source

pub fn from_offsets(offset_se: i8, offset_sw: i8) -> MainWind

Returns the given Main Wind direction according to the given offsets.

  • offset_se must be in [-1, 1]
  • offset_sw must be in [-1, 1]
§Example
use cdshealpix::compass_point::MainWind;
use cdshealpix::compass_point::MainWind::{S, SE, E, SW, C, NE, W, NW, N};

assert_eq!(MainWind::from_offsets(-1, -1),  S);
assert_eq!(MainWind::from_offsets( 0, -1), SE);
assert_eq!(MainWind::from_offsets( 1, -1),  E);
assert_eq!(MainWind::from_offsets(-1,  0), SW);
assert_eq!(MainWind::from_offsets( 0,  0),  C);
assert_eq!(MainWind::from_offsets( 1,  0), NE);
assert_eq!(MainWind::from_offsets(-1,  1),  W);
assert_eq!(MainWind::from_offsets( 0,  1), NW);
assert_eq!(MainWind::from_offsets( 1,  1),  N);

Trait Implementations§

source§

impl Debug for MainWind

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq for MainWind

source§

fn eq(&self, other: &MainWind) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for MainWind

source§

impl StructuralPartialEq for MainWind

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.