#[repr(C)]pub struct Point<T1, T2> {
pub xcoord: T1,
pub ycoord: T2,
}Expand description
Generic Point struct with x and y coordinates
This struct represents a point in 2D space with coordinates of potentially different types. It provides various operations and functionalities for working with points, such as comparison operators, arithmetic operators, flipping, overlap checking, distance calculation, and more.
Properties:
xcoord: The x-coordinate of the pointycoord: The y-coordinate of the point
Fields§
§xcoord: T1x portion of the Point object
ycoord: T2y portion of the Point object
Implementations§
Source§impl<T1, T2> Point<T1, T2>
impl<T1, T2> Point<T1, T2>
Sourcepub fn xcoord_mut(&mut self) -> &mut T1
pub fn xcoord_mut(&mut self) -> &mut T1
Returns a mutable reference to the x-coordinate
Sourcepub fn ycoord_mut(&mut self) -> &mut T2
pub fn ycoord_mut(&mut self) -> &mut T2
Returns a mutable reference to the y-coordinate
Trait Implementations§
Source§impl<'a, 'b, T1: Clone + Num, T2: Clone + Num> Add<&'b Vector2<T1, T2>> for &'a Point<T1, T2>
impl<'a, 'b, T1: Clone + Num, T2: Clone + Num> Add<&'b Vector2<T1, T2>> for &'a Point<T1, T2>
Source§impl<T1: Clone + Num, T2: Clone + Num> Add<Vector2<T1, T2>> for Point<T1, T2>
impl<T1: Clone + Num, T2: Clone + Num> Add<Vector2<T1, T2>> for Point<T1, T2>
Source§fn add(self, other: Vector2<T1, T2>) -> Self::Output
fn add(self, other: Vector2<T1, T2>) -> Self::Output
Translate a point by a vector
§Examples
use physdes::point::Point;
use physdes::vector2::Vector2;
assert_eq!(Point::new(3, 4) + Vector2::new(5, 3), Point::new(8, 7));
assert_eq!(Point::new(3, 4) + Vector2::new(-5, -3), Point::new(-2, 1));
assert_eq!(Point::new(3, 4) + Vector2::new(5, -3), Point::new(8, 1));
assert_eq!(Point::new(3, 4) + Vector2::new(-5, 3), Point::new(-2, 7));
assert_eq!(Point::new(3, 4) + Vector2::new(0, 0), Point::new(3, 4));
assert_eq!(Point::new(3, 4) + Vector2::new(0, 5), Point::new(3, 9));Source§impl<'a, T1: Clone + Num + AddAssign, T2: Clone + Num + AddAssign> AddAssign<&'a Vector2<T1, T2>> for Point<T1, T2>
impl<'a, T1: Clone + Num + AddAssign, T2: Clone + Num + AddAssign> AddAssign<&'a Vector2<T1, T2>> for Point<T1, T2>
Source§fn add_assign(&mut self, other: &'a Vector2<T1, T2>)
fn add_assign(&mut self, other: &'a Vector2<T1, T2>)
+= operation. Read moreSource§impl<T1: Clone + Num + AddAssign, T2: Clone + Num + AddAssign> AddAssign<Vector2<T1, T2>> for Point<T1, T2>
impl<T1: Clone + Num + AddAssign, T2: Clone + Num + AddAssign> AddAssign<Vector2<T1, T2>> for Point<T1, T2>
Source§fn add_assign(&mut self, other: Vector2<T1, T2>)
fn add_assign(&mut self, other: Vector2<T1, T2>)
+= operation. Read moreSource§impl<T1, T2> Displacement<Point<T1, T2>> for Point<T1, T2>where
T1: Displacement<T1, Output = T1>,
T2: Displacement<T2, Output = T2>,
impl<T1, T2> Displacement<Point<T1, T2>> for Point<T1, T2>where
T1: Displacement<T1, Output = T1>,
T2: Displacement<T2, Output = T2>,
Source§impl<T1: Clone + Num + Neg<Output = T1>, T2: Clone + Num + Neg<Output = T2>> Neg for &Point<T1, T2>
impl<T1: Clone + Num + Neg<Output = T1>, T2: Clone + Num + Neg<Output = T2>> Neg for &Point<T1, T2>
Source§impl<T1: Clone + Num + Neg<Output = T1>, T2: Clone + Num + Neg<Output = T2>> Neg for Point<T1, T2>
impl<T1: Clone + Num + Neg<Output = T1>, T2: Clone + Num + Neg<Output = T2>> Neg for Point<T1, T2>
Source§impl<T1: Ord, T2: Ord> Ord for Point<T1, T2>
impl<T1: Ord, T2: Ord> Ord for Point<T1, T2>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T1: PartialOrd, T2: PartialOrd> PartialOrd for Point<T1, T2>
impl<T1: PartialOrd, T2: PartialOrd> PartialOrd for Point<T1, T2>
Source§impl<'a, 'b, T1: Clone + Num, T2: Clone + Num> Sub<&'b Vector2<T1, T2>> for &'a Point<T1, T2>
impl<'a, 'b, T1: Clone + Num, T2: Clone + Num> Sub<&'b Vector2<T1, T2>> for &'a Point<T1, T2>
Source§impl<T1: Clone + Num, T2: Clone + Num> Sub<Vector2<T1, T2>> for Point<T1, T2>
impl<T1: Clone + Num, T2: Clone + Num> Sub<Vector2<T1, T2>> for Point<T1, T2>
Source§fn sub(self, other: Vector2<T1, T2>) -> Self::Output
fn sub(self, other: Vector2<T1, T2>) -> Self::Output
Translate a point by a vector (subtraction)
§Examples
use physdes::point::Point;
use physdes::vector2::Vector2;
assert_eq!(Point::new(3, 4) - Vector2::new(5, 3), Point::new(-2, 1));
assert_eq!(Point::new(3, 4) - Vector2::new(-5, -3), Point::new(8, 7));
assert_eq!(Point::new(3, 4) - Vector2::new(5, -3), Point::new(-2, 7));
assert_eq!(Point::new(3, 4) - Vector2::new(-5, 3), Point::new(8, 1));
assert_eq!(Point::new(3, 4) - Vector2::new(0, 0), Point::new(3, 4));
assert_eq!(Point::new(3, 4) - Vector2::new(0, 5), Point::new(3, -1));
assert_eq!(Point::new(3, 4) - Vector2::new(5, 0), Point::new(-2, 4));Source§impl<T1: Clone + Num, T2: Clone + Num> Sub for Point<T1, T2>
impl<T1: Clone + Num, T2: Clone + Num> Sub for Point<T1, T2>
Source§fn sub(self, other: Self) -> Self::Output
fn sub(self, other: Self) -> Self::Output
Calculate displacement vector between two points
§Examples
use physdes::point::Point;
use physdes::vector2::Vector2;
assert_eq!(Point::new(3, 4) - Point::new(5, 3), Vector2::new(-2, 1));
assert_eq!(Point::new(3, 4) - Point::new(-5, -3), Vector2::new(8, 7));
assert_eq!(Point::new(3, 4) - Point::new(5, -3), Vector2::new(-2, 7));
assert_eq!(Point::new(3, 4) - Point::new(-5, 3), Vector2::new(8, 1));
assert_eq!(Point::new(3, 4) - Point::new(0, 0), Vector2::new(3, 4));Source§impl<'a, T1: Clone + Num + SubAssign, T2: Clone + Num + SubAssign> SubAssign<&'a Vector2<T1, T2>> for Point<T1, T2>
impl<'a, T1: Clone + Num + SubAssign, T2: Clone + Num + SubAssign> SubAssign<&'a Vector2<T1, T2>> for Point<T1, T2>
Source§fn sub_assign(&mut self, other: &'a Vector2<T1, T2>)
fn sub_assign(&mut self, other: &'a Vector2<T1, T2>)
-= operation. Read moreSource§impl<T1: Clone + Num + SubAssign, T2: Clone + Num + SubAssign> SubAssign<Vector2<T1, T2>> for Point<T1, T2>
impl<T1: Clone + Num + SubAssign, T2: Clone + Num + SubAssign> SubAssign<Vector2<T1, T2>> for Point<T1, T2>
Source§fn sub_assign(&mut self, other: Vector2<T1, T2>)
fn sub_assign(&mut self, other: Vector2<T1, T2>)
-= operation. Read moreimpl<T1: Copy, T2: Copy> Copy for Point<T1, T2>
impl<T1: Eq, T2: Eq> Eq for Point<T1, T2>
impl<T1, T2> StructuralPartialEq for Point<T1, T2>
Auto Trait Implementations§
impl<T1, T2> Freeze for Point<T1, T2>
impl<T1, T2> RefUnwindSafe for Point<T1, T2>where
T1: RefUnwindSafe,
T2: RefUnwindSafe,
impl<T1, T2> Send for Point<T1, T2>
impl<T1, T2> Sync for Point<T1, T2>
impl<T1, T2> Unpin for Point<T1, T2>
impl<T1, T2> UnwindSafe for Point<T1, T2>where
T1: UnwindSafe,
T2: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Contain<Interval<T>> for Twhere
T: PartialOrd,
impl<T> Contain<Interval<T>> for Twhere
T: PartialOrd,
Source§fn contains(&self, _other: &Interval<T>) -> bool
fn contains(&self, _other: &Interval<T>) -> bool
The function contains always returns false and takes a reference to another Interval as
input.
Arguments:
_other: The_otherparameter is a reference to anIntervalobject of the same typeTas the current object.
Returns:
The contains function is returning a boolean value false.
Source§impl<T> Intersect<Interval<T>> for T
impl<T> Intersect<Interval<T>> for T
Source§fn intersect_with(
&self,
other: &Interval<T>,
) -> <T as Intersect<Interval<T>>>::Output
fn intersect_with( &self, other: &Interval<T>, ) -> <T as Intersect<Interval<T>>>::Output
The intersect_with function in Rust swaps the receiver and argument before calling the
intersect_with method on the argument.
Arguments:
other: Theotherparameter in theintersect_withfunction represents anotherInterval<T>that you want to intersect with the current interval.
type Output = Interval<T>
Source§impl<T> Overlap<Interval<T>> for Twhere
T: PartialOrd,
impl<T> Overlap<Interval<T>> for Twhere
T: PartialOrd,
Source§fn overlaps(&self, other: &Interval<T>) -> bool
fn overlaps(&self, other: &Interval<T>) -> bool
The overlaps function in Rust checks if two intervals overlap with each other.
Arguments:
other: Theotherparameter is a reference to anInterval<T>struct, which represents another interval. TheInterval<T>struct likely contains two fields,lbandub, representing the lower and upper bounds of the interval, respectively. Theoverlapsmethod is used to
Returns:
The overlaps function is returning a boolean value. It checks if the current interval (self)
overlaps with another interval (other) by comparing their lower bounds and upper bounds. If
there is any overlap between the two intervals, it returns true, otherwise it returns false.