Struct hexgrid::Coordinate
[−]
[src]
pub struct Coordinate { /* fields omitted */ }
A hex coordinate using a cubic coordinate scheme.
See http://www.redblobgames.com/grids/hexagons/#coordinates for more detail.
All three coordinates must sum to zero.
Methods
impl Coordinate
[src]
fn new() -> Result<Self, &'static str>
Create a new Coordinate at 0, 0, 0.
This returns a Result
to match at
, but always succeeds.
fn at(x: i64, y: i64, z: i64) -> Result<Self, &'static str>
Create a new Coordinate at the specified location, if that location is valid.
fn neighbors(&self) -> Vec<Coordinate>
Get the six neighbors of a given Coordinate.
fn neighbor(&self, direction: usize) -> Result<Coordinate, &'static str>
Get the neighbor in direction
. Valid directions are in [0, 5].
fn distance_to(&self, other: Coordinate) -> i64
Get the distance between two coordinates, in grid tiles.
Trait Implementations
impl Debug for Coordinate
[src]
impl PartialEq for Coordinate
[src]
fn eq(&self, __arg_0: &Coordinate) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Coordinate) -> bool
This method tests for !=
.
impl PartialOrd for Coordinate
[src]
fn partial_cmp(&self, __arg_0: &Coordinate) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Coordinate) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Coordinate) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Coordinate) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Coordinate) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Clone for Coordinate
[src]
fn clone(&self) -> Coordinate
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Copy for Coordinate
[src]
impl Add for Coordinate
[src]
type Output = Coordinate
The resulting type after applying the +
operator
fn add(self, other: Coordinate) -> Coordinate
The method for the +
operator
impl Sub for Coordinate
[src]
type Output = Coordinate
The resulting type after applying the -
operator
fn sub(self, other: Coordinate) -> Coordinate
The method for the -
operator