Enum aglet::Direction8
source · [−]pub enum Direction8 {
North,
NorthEast,
East,
SouthEast,
South,
SouthWest,
West,
NorthWest,
}Expand description
Eight-way directions.
These start at North and increment counter-clockwise,
so you can convert them to integers with as and use them
in rotational calculations if you need.
Variants
North
NorthEast
East
SouthEast
South
SouthWest
West
NorthWest
Implementations
sourceimpl Direction8
impl Direction8
sourcepub const DIRECTIONS: [Direction8; 8] = _
pub const DIRECTIONS: [Direction8; 8] = _
All the directions in order. This is used internally for rotations and flips. I made it public just in case it’s helpful for you the programmer.
sourcepub fn rotate_by(self, steps_clockwise: i32) -> Self
pub fn rotate_by(self, steps_clockwise: i32) -> Self
Get this direction, rotated by this many steps clockwise. Negative numbers go counter-clockwise.
sourcepub fn radians(self) -> f32
pub fn radians(self) -> f32
Get this direction in radians.
This uses trigonometric + graphical standard, where:
- 0 radians is to the right
- Positive radians increment clockwise. NOTE: this is opposite from normal trig, but makes sense in computer graphics where +Y is downwards.
If you need it in degrees just call .to_degrees on the result.
Trait Implementations
sourceimpl Add<Direction8> for CoordVec
impl Add<Direction8> for CoordVec
sourceimpl AddAssign<Direction8> for CoordVec
impl AddAssign<Direction8> for CoordVec
sourcefn add_assign(&mut self, rhs: Direction8)
fn add_assign(&mut self, rhs: Direction8)
Performs the += operation. Read more
sourceimpl Clone for Direction8
impl Clone for Direction8
sourcefn clone(&self) -> Direction8
fn clone(&self) -> Direction8
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for Direction8
impl Debug for Direction8
sourceimpl From<Direction4> for Direction8
impl From<Direction4> for Direction8
sourcefn from(d4: Direction4) -> Self
fn from(d4: Direction4) -> Self
Converts to this type from the input type.
sourceimpl From<Direction8> for Direction8Set
impl From<Direction8> for Direction8Set
sourcefn from(dir: Direction8) -> Self
fn from(dir: Direction8) -> Self
Converts to this type from the input type.
sourceimpl From<Direction8> for Direction9
impl From<Direction8> for Direction9
sourcefn from(dir: Direction8) -> Self
fn from(dir: Direction8) -> Self
Converts to this type from the input type.
sourceimpl Hash for Direction8
impl Hash for Direction8
sourceimpl Ord for Direction8
impl Ord for Direction8
sourceimpl PartialEq<Direction8> for Direction8
impl PartialEq<Direction8> for Direction8
sourceimpl PartialOrd<Direction8> for Direction8
impl PartialOrd<Direction8> for Direction8
sourcefn partial_cmp(&self, other: &Direction8) -> Option<Ordering>
fn partial_cmp(&self, other: &Direction8) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl TryFrom<Direction9> for Direction8
impl TryFrom<Direction9> for Direction8
impl Copy for Direction8
impl Eq for Direction8
impl StructuralEq for Direction8
impl StructuralPartialEq for Direction8
Auto Trait Implementations
impl RefUnwindSafe for Direction8
impl Send for Direction8
impl Sync for Direction8
impl Unpin for Direction8
impl UnwindSafe for Direction8
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more