pub struct Point2d<T = i64> {
pub x: T,
pub y: T,
}
Expand description
A 2d point where you can choose the type and thus precision of the x and y indices. By default uses i64 which is the world coordinate type.
Fields§
§x: T
x
position
y: T
y
position
Implementations§
Source§impl<C: Chunk> Point2d<GridIndex<C>>
impl<C: Chunk> Point2d<GridIndex<C>>
Sourcepub fn into_same_chunk_size<D: Chunk>(self) -> GridPoint<D>
pub fn into_same_chunk_size<D: Chunk>(self) -> GridPoint<D>
When two Chunks have the same size, all their coordinates are trivially the same and we can convert them with just a compile-time check.
Source§impl<T: Copy> Point2d<T>
impl<T: Copy> Point2d<T>
Source§impl<T: Copy + Sub<Output = T> + Mul<Output = T> + Add<Output = T> + Abs> Point2d<T>
impl<T: Copy + Sub<Output = T> + Mul<Output = T> + Add<Output = T> + Abs> Point2d<T>
Sourcepub fn dist_squared(self, center: Point2d<T>) -> T
pub fn dist_squared(self, center: Point2d<T>) -> T
The square of the distance between two points
Sourcepub fn len_squared(self) -> T
pub fn len_squared(self) -> T
The square of the distance between the origin (0, 0
) and this point.
Sourcepub fn manhattan_dist(self, city: Point2d<T>) -> T
pub fn manhattan_dist(self, city: Point2d<T>) -> T
The manhattan distance between two points.
Sourcepub fn manhattan_len(&self) -> T
pub fn manhattan_len(&self) -> T
The manhattan distance to the origin.
Trait Implementations§
Source§impl<T: AddAssign> AddAssign for Point2d<T>
impl<T: AddAssign> AddAssign for Point2d<T>
Source§fn add_assign(&mut self, rhs: Point2d<T>)
fn add_assign(&mut self, rhs: Point2d<T>)
Performs the
+=
operation. Read moreSource§impl<T> Distribution<Point2d<T>> for StandardUniformwhere
StandardUniform: Distribution<T>,
impl<T> Distribution<Point2d<T>> for StandardUniformwhere
StandardUniform: Distribution<T>,
Source§impl<T: DivAssign + Copy> DivAssign<T> for Point2d<T>
impl<T: DivAssign + Copy> DivAssign<T> for Point2d<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/=
operation. Read moreSource§impl<T: DivAssign> DivAssign for Point2d<T>
impl<T: DivAssign> DivAssign for Point2d<T>
Source§fn div_assign(&mut self, rhs: Point2d<T>)
fn div_assign(&mut self, rhs: Point2d<T>)
Performs the
/=
operation. Read moreSource§impl From<Point2d<NonZero<u16>>> for Point2d
impl From<Point2d<NonZero<u16>>> for Point2d
Source§fn from(value: Point2d<NonZeroU16>) -> Self
fn from(value: Point2d<NonZeroU16>) -> Self
Converts to this type from the input type.
Source§impl<T: MulAssign + Copy> MulAssign<T> for Point2d<T>
impl<T: MulAssign + Copy> MulAssign<T> for Point2d<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*=
operation. Read moreSource§impl<T: MulAssign> MulAssign for Point2d<T>
impl<T: MulAssign> MulAssign for Point2d<T>
Source§fn mul_assign(&mut self, rhs: Point2d<T>)
fn mul_assign(&mut self, rhs: Point2d<T>)
Performs the
*=
operation. Read moreSource§impl<T: Ord> Ord for Point2d<T>
impl<T: Ord> Ord for Point2d<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Point2d<T>
impl<T: PartialOrd> PartialOrd for Point2d<T>
Source§impl<T: SubAssign> SubAssign for Point2d<T>
impl<T: SubAssign> SubAssign for Point2d<T>
Source§fn sub_assign(&mut self, rhs: Point2d<T>)
fn sub_assign(&mut self, rhs: Point2d<T>)
Performs the
-=
operation. Read moreimpl<T: Copy> Copy for Point2d<T>
impl<T: Eq> Eq for Point2d<T>
impl<T> StructuralPartialEq for Point2d<T>
Auto Trait Implementations§
impl<T> Freeze for Point2d<T>where
T: Freeze,
impl<T> RefUnwindSafe for Point2d<T>where
T: RefUnwindSafe,
impl<T> Send for Point2d<T>where
T: Send,
impl<T> Sync for Point2d<T>where
T: Sync,
impl<T> Unpin for Point2d<T>where
T: Unpin,
impl<T> UnwindSafe for Point2d<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more