pub struct Point<T: Float> { /* private fields */ }
Expand description
Point
The structure is used to store a pair of floating point coordinates with float precision(between 32 or 64 bits).
Examples
use points::Point;
let p1: Point<f64> = Point::default();
let p2 = Point::new(1.0, 3.0);
assert_eq!(Point::new(-1.0, -3.0), p1 - p2);
Whole expression
use points::Point;
// execute (a + b) * 3 + (a - c)
let a: Point<f64> = Point::default();
let b = Point::new(1.0, 3.0);
let c = Point::new(1.5, 2.5);
let result = (a + b) * 3.0 + (a - c);
assert_eq!(Point::new(1.5, 6.5), result);
Implementations§
source§impl<T: Float> Point<T>
impl<T: Float> Point<T>
sourcepub fn distance_to(&self, point: Point<T>) -> T
pub fn distance_to(&self, point: Point<T>) -> T
Calculates the Euclidean distance between two points.
sourcepub fn squared_distance_to(&self, point: Point<T>) -> T
pub fn squared_distance_to(&self, point: Point<T>) -> T
Calculates the squared Euclidean distance between two points.
sourcepub fn euclidean_norm(&self) -> T
pub fn euclidean_norm(&self) -> T
Calculates the Euclidean norm of the vector comprised of the point’s coordinates. Distance from origin point(0, 0).
Trait Implementations§
source§impl<T: Float> PartialEq for Point<T>
impl<T: Float> PartialEq for Point<T>
impl<T: Copy + Float> Copy for Point<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Point<T>where
T: RefUnwindSafe,
impl<T> Send for Point<T>where
T: Send,
impl<T> Sync for Point<T>where
T: Sync,
impl<T> Unpin for Point<T>where
T: Unpin,
impl<T> UnwindSafe for Point<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