pub struct Point2D<T: Number> {
pub x: T,
pub y: T,
}
Expand description
Struct representing a 2D point or vector.
Fields§
§x: T
§y: T
Implementations§
source§impl<T: Number> Point2D<T>
impl<T: Number> Point2D<T>
pub const ORIGIN: Self = _
pub const fn new(x: T, y: T) -> Self
sourcepub fn manhattan_distance(self) -> T
pub fn manhattan_distance(self) -> T
Returns the manhattan distance from the origin.
sourcepub fn manhattan_distance_unsigned(self) -> T::Unsignedwhere
T: SignedInteger,
pub fn manhattan_distance_unsigned(self) -> T::Unsignedwhere
T: SignedInteger,
Returns the manhattan distance from the origin.
sourcepub fn wrapping_add_signed(self, rhs: Point2D<T::Signed>) -> Selfwhere
T: UnsignedInteger,
pub fn wrapping_add_signed(self, rhs: Point2D<T::Signed>) -> Selfwhere
T: UnsignedInteger,
Add the provided signed point, wrapping on overflow.
Useful for adding a signed direction onto an unsigned position.
Trait Implementations§
source§impl<T: Number> AddAssign for Point2D<T>
impl<T: Number> AddAssign for Point2D<T>
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl<T: Number> MulAssign<T> for Point2D<T>
impl<T: Number> 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: Ord + Number> Ord for Point2D<T>
impl<T: Ord + Number> 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 + Number> PartialOrd for Point2D<T>
impl<T: PartialOrd + Number> PartialOrd for Point2D<T>
source§impl<T: Number> SubAssign for Point2D<T>
impl<T: Number> SubAssign for Point2D<T>
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl<T: Copy + Number> Copy for Point2D<T>
impl<T: Eq + Number> Eq for Point2D<T>
impl<T: Number> 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)