Struct hexagon_map::AxialPoint
source · pub struct AxialPoint {
pub q: isize,
pub r: isize,
}Expand description
A point in axial coordinates, standard form of a hexagon map
Fields§
§q: isize§r: isizeImplementations§
source§impl AxialPoint
impl AxialPoint
sourcepub fn from_pixel(x: f64, y: f64, radius: f64) -> Self
pub fn from_pixel(x: f64, y: f64, radius: f64) -> Self
Create a new point in axial coordinates from pixel coordinates
sourcepub fn get_center(&self, radius: f64) -> (f64, f64)
pub fn get_center(&self, radius: f64) -> (f64, f64)
Get the pixel coordinates of the center of the hexagon
sourcepub fn get_corners(&self, radius: f64) -> [(f64, f64); 6]
pub fn get_corners(&self, radius: f64) -> [(f64, f64); 6]
Get the pixel coordinates of the corners of the hexagon
pub fn nearby(&self) -> Vec<Self>
source§impl AxialPoint
impl AxialPoint
sourcepub fn go(&self, direction: Direction) -> Self
pub fn go(&self, direction: Direction) -> Self
Get the pixel coordinates of the center of the hexagon
sourcepub fn euclidean_distance(&self, other: &Self, radius: f64) -> f64
pub fn euclidean_distance(&self, other: &Self, radius: f64) -> f64
Calculate the euclidean distance between two points
sourcepub fn manhattan_distance(&self, other: &Self) -> usize
pub fn manhattan_distance(&self, other: &Self) -> usize
Calculate the manhattan distance between two points
Trait Implementations§
source§impl Clone for AxialPoint
impl Clone for AxialPoint
source§fn clone(&self) -> AxialPoint
fn clone(&self) -> AxialPoint
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for AxialPoint
impl Debug for AxialPoint
source§impl<'de> Deserialize<'de> for AxialPoint
impl<'de> Deserialize<'de> for AxialPoint
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for AxialPoint
impl Display for AxialPoint
source§impl From<AxialPoint> for HPoint
impl From<AxialPoint> for HPoint
source§fn from(point: AxialPoint) -> Self
fn from(point: AxialPoint) -> Self
Converts to this type from the input type.
source§impl From<AxialPoint> for SPoint
impl From<AxialPoint> for SPoint
source§fn from(point: AxialPoint) -> Self
fn from(point: AxialPoint) -> Self
Converts to this type from the input type.
source§impl From<AxialPoint> for WPoint
impl From<AxialPoint> for WPoint
source§fn from(point: AxialPoint) -> Self
fn from(point: AxialPoint) -> Self
Converts to this type from the input type.
source§impl Hash for AxialPoint
impl Hash for AxialPoint
source§impl Into<AxialPoint> for HPoint
impl Into<AxialPoint> for HPoint
source§fn into(self) -> AxialPoint
fn into(self) -> AxialPoint
Converts this type into the (usually inferred) input type.
source§impl Into<AxialPoint> for SPoint
impl Into<AxialPoint> for SPoint
source§fn into(self) -> AxialPoint
fn into(self) -> AxialPoint
Converts this type into the (usually inferred) input type.
source§impl Into<AxialPoint> for WPoint
impl Into<AxialPoint> for WPoint
source§fn into(self) -> AxialPoint
fn into(self) -> AxialPoint
Converts this type into the (usually inferred) input type.
source§impl Ord for AxialPoint
impl Ord for AxialPoint
source§fn cmp(&self, other: &AxialPoint) -> Ordering
fn cmp(&self, other: &AxialPoint) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<AxialPoint> for AxialPoint
impl PartialEq<AxialPoint> for AxialPoint
source§fn eq(&self, other: &AxialPoint) -> bool
fn eq(&self, other: &AxialPoint) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PartialOrd<AxialPoint> for AxialPoint
impl PartialOrd<AxialPoint> for AxialPoint
source§fn partial_cmp(&self, other: &AxialPoint) -> Option<Ordering>
fn partial_cmp(&self, other: &AxialPoint) -> Option<Ordering>
1.0.0 · source§fn 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