[][src]Struct beehive::Point

#[repr(C)]pub struct Point<T> { /* fields omitted */ }

Cube hex coordinates representing points. Only valid points on the plane can be normally created.

T should generally be a signed integer type. Floating point numbers have precision problems that may lead to invalid coordinates after operations.

Methods

impl<T> Point<T>[src]

pub fn x(&self) -> &T[src]

pub fn y(&self) -> &T[src]

pub fn z(&self) -> &T[src]

pub fn w(&self) -> &T[src]

pub fn into_axial(self) -> PointAxial<T>[src]

impl<T: Copy + Add + Zero> Point<T>[src]

pub fn try_from_coords(x: T, y: T, z: T, w: T) -> Option<Self>[src]

Create from coordinates. Returns None if invalid.

pub fn new(x: T, y: T, z: T, w: T) -> Self[src]

Create from coordinates. Will panic if invalid.

Panics

The function panics when called with coordinates that don't satisfy the hex plane invariant.

impl<T: Zero> Point<T>[src]

pub fn zero() -> Self[src]

Return a vector where all components are zero.

impl<T: Real> Point<T>[src]

pub fn round(self) -> Self[src]

Round in hex space, upholding plane invariant.

pub fn cast_round<N>(self) -> Point<N> where
    N: 'static + Copy,
    T: AsPrimitive<N>, 
[src]

Round in hex space and cast to a primitive type.

N must be a primitive numeric type.

impl<T> Point<T>[src]

pub fn cast_fix<N>(self) -> Point<N> where
    N: 'static + Copy + Add + Zero + Sub<Output = N>,
    T: AsPrimitive<N>, 
[src]

Cast to a primitive type and fix the coordinate if necessary, by discarding the Z-axis. This is preferable for integral Ts.

N must be a primitive numeric type.

impl<T> Point<T>[src]

pub fn into_vector(self) -> Vector<T>[src]

Convert this point to a vector with the same component values.

impl<T> Point<T> where
    T: 'static + Copy + AsPrimitive<f32>,
    f32: AsPrimitive<T>, 
[src]

pub fn line_to(self, other: Point<T>) -> Line<T>[src]

Creates a line iterator to other, including both endpoints.

pub fn line_from(self, other: Point<T>) -> Line<T>[src]

Creates a line iterator from other, including both endpoints.

pub fn line_to_excluding(
    self,
    other: Point<T>,
    exclude_start: bool,
    exclude_end: bool
) -> Line<T>
[src]

Creates a line iterator to other, excluding some endpoints.

pub fn line_from_excluding(
    self,
    other: Point<T>,
    exclude_start: bool,
    exclude_end: bool
) -> Line<T>
[src]

Creates a line iterator from other, excluding some endpoints.

impl<T: Copy + Signed + One + Add + Sub<Output = T> + Div> Point<T>[src]

pub fn distance(&self, other: Point<T>) -> T[src]

Returns the manhattan distance to another point in hex space.

Trait Implementations

impl<T> Add<Direction> for Point<T> where
    T: Zero + One + Add + Neg<Output = T>, 
[src]

type Output = Point<T>

The resulting type after applying the + operator.

impl<T, O> Add<Vector<T>> for Point<T> where
    T: Add<Output = O>, 
[src]

type Output = Point<O>

The resulting type after applying the + operator.

impl<T> AddAssign<Direction> for Point<T> where
    T: Zero + One + AddAssign<T> + Neg<Output = T>, 
[src]

impl<T> AddAssign<Vector<T>> for Point<T> where
    T: AddAssign
[src]

impl<T: Clone> Clone for Point<T>[src]

impl<T: Copy> Copy for Point<T>[src]

impl<T: Debug> Debug for Point<T>[src]

impl<T: Default> Default for Point<T>[src]

impl<T: Display> Display for Point<T>[src]

impl<T: Eq> Eq for Point<T>[src]

impl<T> Extend<Point<T>> for QuadPrism<T> where
    T: PartialOrd + One + Add<Output = T>, 
[src]

impl<T> From<Point<T>> for PointAxial<T>[src]

impl<V> From<Point<V>> for Geom<V>[src]

impl<T: Copy + Zero + Sub<Output = T>> From<PointAxial<T>> for Point<T>[src]

impl<T> FromIterator<Point<T>> for QuadPrism<T> where
    T: Copy + Default + PartialOrd + One + Add<Output = T>, 
[src]

impl<T: Hash> Hash for Point<T>[src]

impl<T, I: Subscript> Index<Point<I>> for HexMap<T, I>[src]

type Output = T

The returned type after indexing.

impl<T, I: Subscript> IndexMut<Point<I>> for HexMap<T, I>[src]

impl<T: PartialEq> PartialEq<Point<T>> for Point<T>[src]

impl<T> StructuralEq for Point<T>[src]

impl<T> StructuralPartialEq for Point<T>[src]

impl<T> Sub<Direction> for Point<T> where
    T: Zero + One + Sub<Output = T> + Neg<Output = T>, 
[src]

type Output = Point<T>

The resulting type after applying the - operator.

impl<T, O> Sub<Point<T>> for Point<T> where
    T: Sub<Output = O>, 
[src]

type Output = Vector<O>

The resulting type after applying the - operator.

impl<T, O> Sub<Vector<T>> for Point<T> where
    T: Sub<Output = O>, 
[src]

type Output = Point<O>

The resulting type after applying the - operator.

impl<T> SubAssign<Direction> for Point<T> where
    T: Zero + One + SubAssign<T> + Neg<Output = T>, 
[src]

impl<T> SubAssign<Vector<T>> for Point<T> where
    T: SubAssign
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Point<T> where
    T: RefUnwindSafe

impl<T> Send for Point<T> where
    T: Send

impl<T> Sync for Point<T> where
    T: Sync

impl<T> Unpin for Point<T> where
    T: Unpin

impl<T> UnwindSafe for Point<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.