[][src]Struct beehive::Vector

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

Cube hex coordinates representing vectors. 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> Vector<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) -> VectorAxial<T>[src]

impl<T: Copy + Add + Zero> Vector<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> Vector<T>[src]

pub fn zero() -> Self[src]

Return a vector where all components are zero.

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

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

Round in hex space, upholding plane invariant.

pub fn cast_round<N>(self) -> Vector<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> Vector<T>[src]

pub fn cast_fix<N>(self) -> Vector<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> Vector<T>[src]

pub fn into_point(self) -> Point<T>[src]

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

impl<T: Zero + One + Neg<Output = T>> Vector<T>[src]

Direction vectors.

Flat:

       yz +Y
       __
   yx /  \ xz +X
-X zx \__/ xy
    -Y zy

Pointy:

    yx  /\  yz  +Y
-X  zx |  | xz  +X
-Y  zy  \/  xy

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

+Y -Z direction vector.

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

+X -Z direction vector.

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

+X -Y direction vector.

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

+Z -Y direction vector.

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

+Z -X direction vector.

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

+Y -X direction vector.

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

+W direction vector.

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

-W direction vector.

pub fn directions() -> [Vector<T>; 8][src]

All direction vectors in sequential order.

pub fn in_direction(d: Direction) -> Vector<T>[src]

Get directional vector from a Direction value.

impl<T: Zero + One + Neg<Output = T> + Eq> Vector<T>[src]

pub fn try_into_direction(self) -> Option<Direction>[src]

Return the Direction that represents self, if self is a vector of length 1. Returns None otherwise.

impl<T: Copy + Signed + One + Add + Div> Vector<T>[src]

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

Returns the manhattan length in hex space.

Trait Implementations

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

type Output = Vector<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, O> Add<Vector<T>> for Vector<T> where
    T: Add<Output = O>, 
[src]

type Output = Vector<O>

The resulting type after applying the + operator.

impl<T> AddAssign<Direction> for Vector<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> AddAssign<Vector<T>> for Vector<T> where
    T: AddAssign
[src]

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

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

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

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

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

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

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

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

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

impl<T, O> Mul<T> for Vector<T> where
    T: Copy + Mul<Output = O>, 
[src]

type Output = Vector<O>

The resulting type after applying the * operator.

impl<T> MulAssign<T> for Vector<T> where
    T: Copy + MulAssign
[src]

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

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

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

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

type Output = Vector<T>

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, O> Sub<Vector<T>> for Vector<T> where
    T: Sub<Output = O>, 
[src]

type Output = Vector<O>

The resulting type after applying the - operator.

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

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

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

Auto Trait Implementations

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

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

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

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

impl<T> UnwindSafe for Vector<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.