pub struct GridEdge {
pub origin: Hex,
pub direction: EdgeDirection,
}
Expand description
Hexagonal grid orientated edge representation
Fields§
§origin: Hex
The coordinate of the edge
direction: EdgeDirection
The direction the edge points towards
Implementations§
Source§impl GridEdge
impl GridEdge
Sourcepub fn equivalent(&self, other: &GridEdge) -> bool
pub fn equivalent(&self, other: &GridEdge) -> bool
Edges are equivalent if they have identical or flipped origin or direction
Sourcepub const fn destination(&self) -> Hex
pub const fn destination(&self) -> Hex
Returns the coordinate the edge id pointing to
Sourcepub const fn vertices(&self) -> [GridVertex; 2]
pub const fn vertices(&self) -> [GridVertex; 2]
Returns the two vertices making this edge in clockwise order
Sourcepub const fn flipped(self) -> GridEdge
pub const fn flipped(self) -> GridEdge
Flips the edge, changing its origin
to be the destination
and
inverting its direction
Sourcepub const fn counter_clockwise(self) -> GridEdge
pub const fn counter_clockwise(self) -> GridEdge
Returns the next edge in counter clockwise order
Sourcepub const fn rotate_ccw(self, offset: u8) -> GridEdge
pub const fn rotate_ccw(self, offset: u8) -> GridEdge
Rotates self
counter clockwise by offset
amount.
Trait Implementations§
Source§impl From<EdgeDirection> for GridEdge
impl From<EdgeDirection> for GridEdge
Source§fn from(direction: EdgeDirection) -> GridEdge
fn from(direction: EdgeDirection) -> GridEdge
Converts to this type from the input type.
impl Copy for GridEdge
impl Eq for GridEdge
impl StructuralPartialEq for GridEdge
Auto Trait Implementations§
impl Freeze for GridEdge
impl RefUnwindSafe for GridEdge
impl Send for GridEdge
impl Sync for GridEdge
impl Unpin for GridEdge
impl UnwindSafe for GridEdge
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
Mutably borrows from an owned value. Read more