#[repr(u8)]pub enum Direction {
Down = 0,
Up = 1,
North = 2,
South = 3,
West = 4,
East = 5,
}Expand description
A cardinal direction in 3D space.
Values 0–5 map to Down, Up, North, South, West, East and are used directly as wire IDs in many packets.
Variants§
Down = 0
Negative Y.
Up = 1
Positive Y.
North = 2
Negative Z.
South = 3
Positive Z.
West = 4
Negative X.
East = 5
Positive X.
Implementations§
Source§impl Direction
impl Direction
Sourcepub fn clockwise(self) -> Option<Direction>
pub fn clockwise(self) -> Option<Direction>
Rotates this direction 90° clockwise around the Y axis.
Only valid for horizontal directions.
Returns None for Direction::Up and Direction::Down.
Sourcepub fn counter_clockwise(self) -> Option<Direction>
pub fn counter_clockwise(self) -> Option<Direction>
Rotates this direction 90° counter-clockwise around the Y axis.
Only valid for horizontal directions.
Returns None for Direction::Up and Direction::Down.
Sourcepub fn axis_direction(self) -> AxisDirection
pub fn axis_direction(self) -> AxisDirection
Returns the axis direction (positive or negative) for this direction.
Sourcepub fn from_3d_data_value(id: u8) -> Option<Direction>
pub fn from_3d_data_value(id: u8) -> Option<Direction>
Converts a 3D data value (0–5) to a Direction.
Returns None if id is out of range.
Sourcepub fn from_2d_data_value(id: u8) -> Option<Direction>
pub fn from_2d_data_value(id: u8) -> Option<Direction>
Converts a 2D data value to a horizontal Direction.
Mapping: 0=South, 1=West, 2=North, 3=East.
Returns None if id is out of range.
Sourcepub fn to_3d_data_value(self) -> u8
pub fn to_3d_data_value(self) -> u8
Returns the 3D data value (0–5) for this direction.
Sourcepub fn to_y_rot(self) -> f32
pub fn to_y_rot(self) -> f32
Returns the Y rotation in degrees for this horizontal direction.
South=0, West=90, North=180, East=270. Returns 0.0 for vertical directions.
Sourcepub fn from_y_rot(rot: f64) -> Direction
pub fn from_y_rot(rot: f64) -> Direction
Converts a Y rotation (in degrees) to the nearest horizontal direction.
South=0°, West=90°, North=180°, East=270°.
Sourcepub fn is_horizontal(self) -> bool
pub fn is_horizontal(self) -> bool
Returns true if this is a horizontal direction (North/South/East/West).
Sourcepub fn is_vertical(self) -> bool
pub fn is_vertical(self) -> bool
Returns true if this is a vertical direction (Up/Down).
Trait Implementations§
impl Copy for Direction
impl Eq for Direction
impl StructuralPartialEq for Direction
Auto Trait Implementations§
impl Freeze for Direction
impl RefUnwindSafe for Direction
impl Send for Direction
impl Sync for Direction
impl Unpin for Direction
impl UnsafeUnpin for Direction
impl UnwindSafe for Direction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.