[−][src]Struct beehive::Point
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]
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]
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> Point<T>
[src]
pub fn cast_fix<N>(self) -> Point<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> 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]
T: 'static + Copy + AsPrimitive<f32>,
f32: AsPrimitive<T>,
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]
self,
other: Point<T>,
exclude_start: bool,
exclude_end: bool
) -> Line<T>
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]
self,
other: Point<T>,
exclude_start: bool,
exclude_end: bool
) -> Line<T>
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]
T: Zero + One + Add + Neg<Output = T>,
type Output = Point<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> AddAssign<Direction> for Point<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: 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]
T: PartialOrd + One + Add<Output = T>,
fn extend<I: IntoIterator<Item = Point<T>>>(&mut self, it: I)
[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]
fn from(c: PointAxial<T>) -> Point<T>
[src]
impl<T> FromIterator<Point<T>> for QuadPrism<T> where
T: Copy + Default + PartialOrd + One + Add<Output = T>,
[src]
T: Copy + Default + PartialOrd + One + Add<Output = T>,
fn from_iter<I: IntoIterator<Item = Point<T>>>(it: I) -> Self
[src]
impl<T: Hash> Hash for Point<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, I: Subscript> Index<Point<I>> for HexMap<T, I>
[src]
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]
T: Zero + One + Sub<Output = T> + Neg<Output = T>,
type Output = Point<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Direction) -> Self::Output
[src]
impl<T, O> Sub<Point<T>> for Point<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: Point<T>) -> 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> SubAssign<Direction> for Point<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]
Auto Trait Implementations
impl<T> RefUnwindSafe for Point<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Point<T> where
T: Send,
T: Send,
impl<T> Sync for Point<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Point<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Point<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>,