[−][src]Struct beehive::Vector
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]
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]
N: 'static + Copy,
T: AsPrimitive<N>,
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]
N: 'static + Copy + Add + Zero + Sub<Output = N>,
T: AsPrimitive<N>,
Cast to a primitive type and fix the coordinate if necessary,
by discarding the Z-axis. This is preferable for integral T
s.
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]
Trait Implementations
impl<T> Add<Direction> for Vector<T> where
T: Zero + One + Add + Neg<Output = T>,
[src]
T: Zero + One + Add + Neg<Output = T>,
type Output = Vector<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Direction) -> Self::Output
[src]
impl<T, O> Add<Vector<T>> for Point<T> where
T: Add<Output = O>,
[src]
T: Add<Output = O>,
type Output = Point<O>
The resulting type after applying the +
operator.
fn add(self, rhs: Vector<T>) -> Self::Output
[src]
impl<T, O> Add<Vector<T>> for Vector<T> where
T: Add<Output = O>,
[src]
T: Add<Output = O>,
type Output = Vector<O>
The resulting type after applying the +
operator.
fn add(self, rhs: Vector<T>) -> Self::Output
[src]
impl<T> AddAssign<Direction> for Vector<T> where
T: Zero + One + AddAssign<T> + Neg<Output = T>,
[src]
T: Zero + One + AddAssign<T> + Neg<Output = T>,
fn add_assign(&mut self, rhs: Direction)
[src]
impl<T> AddAssign<Vector<T>> for Point<T> where
T: AddAssign,
[src]
T: AddAssign,
fn add_assign(&mut self, rhs: Vector<T>)
[src]
impl<T> AddAssign<Vector<T>> for Vector<T> where
T: AddAssign,
[src]
T: AddAssign,
fn add_assign(&mut self, rhs: Vector<T>)
[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]
fn from(c: VectorAxial<T>) -> Vector<T>
[src]
impl<T: Hash> Hash for Vector<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, O> Mul<T> for Vector<T> where
T: Copy + Mul<Output = O>,
[src]
T: Copy + Mul<Output = O>,
type Output = Vector<O>
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Self::Output
[src]
impl<T> MulAssign<T> for Vector<T> where
T: Copy + MulAssign,
[src]
T: Copy + MulAssign,
fn mul_assign(&mut self, rhs: T)
[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]
T: Zero + One + Sub<Output = T> + Neg<Output = T>,
type Output = Vector<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Direction) -> Self::Output
[src]
impl<T, O> Sub<Vector<T>> for Point<T> where
T: Sub<Output = O>,
[src]
T: Sub<Output = O>,
type Output = Point<O>
The resulting type after applying the -
operator.
fn sub(self, rhs: Vector<T>) -> Self::Output
[src]
impl<T, O> Sub<Vector<T>> for Vector<T> where
T: Sub<Output = O>,
[src]
T: Sub<Output = O>,
type Output = Vector<O>
The resulting type after applying the -
operator.
fn sub(self, rhs: Vector<T>) -> Self::Output
[src]
impl<T> SubAssign<Direction> for Vector<T> where
T: Zero + One + SubAssign<T> + Neg<Output = T>,
[src]
T: Zero + One + SubAssign<T> + Neg<Output = T>,
fn sub_assign(&mut self, rhs: Direction)
[src]
impl<T> SubAssign<Vector<T>> for Point<T> where
T: SubAssign,
[src]
T: SubAssign,
fn sub_assign(&mut self, rhs: Vector<T>)
[src]
impl<T> SubAssign<Vector<T>> for Vector<T> where
T: SubAssign,
[src]
T: SubAssign,
fn sub_assign(&mut self, rhs: Vector<T>)
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Vector<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Vector<T> where
T: Send,
T: Send,
impl<T> Sync for Vector<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Vector<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Vector<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,