Struct base::math::AxialPoint
[−]
[src]
pub struct AxialPoint { pub q: AxialType, pub r: AxialType, }
A 2-dimensional point in axial coordinates. See here for more information.
Fields
q: AxialType
r: AxialType
Methods
impl AxialPoint
[src]
fn new(q: AxialType, r: AxialType) -> Self
fn to_real(&self) -> Point2f
Returns the position of the hexagons center in the standard coordinate
system using world::{HEX_INNER_RADIUS, HEX_OUTER_RADIUS}
.
fn from_real(real: Point2f) -> Self
Return the AxialPoint
from a Point2f
. It's the pixel to hex
algorithm from redblobgames.com.
fn s(&self) -> AxialType
Returns the s
component of corresponding cube coordinates. In cube
coordinates 'q + r + s = 0', so saving s
is redundant and can be
calculated on the fly when needed.
Trait Implementations
impl Hash for AxialPoint
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl Eq for AxialPoint
[src]
impl PartialEq for AxialPoint
[src]
fn eq(&self, __arg_0: &AxialPoint) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &AxialPoint) -> bool
This method tests for !=
.
impl Copy for AxialPoint
[src]
impl Clone for AxialPoint
[src]
fn clone(&self) -> AxialPoint
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 Debug for AxialPoint
[src]
impl Add<AxialVector> for AxialPoint
[src]
********************Basic Arithmetics************
type Output = AxialPoint
The resulting type after applying the +
operator
fn add(self, rhs: AxialVector) -> AxialPoint
The method for the +
operator
impl Sub<AxialPoint> for AxialPoint
[src]
type Output = AxialVector
The resulting type after applying the -
operator
fn sub(self, rhs: AxialPoint) -> AxialVector
The method for the -
operator
impl Mul<AxialType> for AxialPoint
[src]
type Output = AxialPoint
The resulting type after applying the *
operator
fn mul(self, rhs: AxialType) -> AxialPoint
The method for the *
operator
impl Div<AxialType> for AxialPoint
[src]
type Output = AxialPoint
The resulting type after applying the /
operator
fn div(self, rhs: AxialType) -> AxialPoint
The method for the /
operator
impl Rem<AxialType> for AxialPoint
[src]
type Output = AxialPoint
The resulting type after applying the %
operator
fn rem(self, d: AxialType) -> AxialPoint
The method for the %
operator
impl Index<usize> for AxialPoint
[src]
********************Index************
type Output = AxialType
The returned type after indexing
fn index(&self, index: usize) -> &AxialType
The method for the indexing (Foo[Bar]
) operation
impl IndexMut<usize> for AxialPoint
[src]
fn index_mut(&mut self, index: usize) -> &mut AxialType
The method for the indexing (Foo[Bar]
) operation
impl Array for AxialPoint
[src]
********************Array************
type Element = AxialType
fn from_value(x: AxialType) -> AxialPoint
Construct a vector from a single value, replicating it. Read more
fn sum(self) -> AxialType
The sum of the elements of the array.
fn product(self) -> AxialType
The product of the elements of the array.
fn min(self) -> AxialType
The minimum element of the array.
fn max(self) -> AxialType
The maximum element of the array.
fn as_ptr(&self) -> *const Self::Element
Get the pointer to the first element of the array.
fn as_mut_ptr(&mut self) -> *mut Self::Element
Get a mutable pointer to the first element of the array.
fn swap_elements(&mut self, i: usize, j: usize)
Swap the elements at indices i
and j
in-place.
impl MetricSpace for AxialPoint
[src]
******************* Metric-Space************************
type Metric = f32
The metric to be returned by the distance
function.
fn distance2(self, other: AxialPoint) -> Self::Metric
Returns the squared distance. Read more
fn distance(self, other: Self) -> Self::Metric
The distance between two values.
impl EuclideanSpace for AxialPoint
[src]
******************* EuclideanSpace**********************
type Scalar = i32
The associated scalar over which the space is defined. Read more
type Diff = AxialVector
The associated space of displacement vectors.
fn origin() -> Self
The point at the origin of the Euclidean space.
fn from_vec(v: Self::Diff) -> Self
Convert a displacement vector to a point. Read more
fn to_vec(self) -> Self::Diff
Convert a point to a displacement vector. Read more
fn dot(self, v: Self::Diff) -> Self::Scalar
This is a weird one, but its useful for plane calculations.
fn midpoint(self, other: Self) -> Self
Returns the middle point between two other points. Read more
fn centroid(points: &[Self]) -> Self
Returns the average position of all points in the slice. Read more