pub struct Point<const D: usize, T: ExtendedNumOps> {
pub vec: [T; D],
}
Expand description
The basic input type for constructing and simplifying a polyline. It can have any number of components, and will work with components that implement the ExtendedNumOps type. Dimensionality must be determined at compile time.
This also implements some basic math operations between points, like:
- addition
- subtraction
- component-wise multiplication
- scalar multiplication
§Example
use simplify_polyline::*;
let point2d: Point<2, i32> = Point { vec: [1, 1] };
let another_point2d: Point<2, i32> = Point { vec: [2, 2] };
assert_eq!(point2d + another_point2d, Point { vec: [3, 3] });
assert_eq!(point2d - another_point2d, Point { vec: [-1, -1] });
assert_eq!(point2d * another_point2d, Point { vec: [2, 2] });
assert_eq!(point2d * 7, Point { vec: [7, 7] });
Fields§
§vec: [T; D]
The components of the point.
Implementations§
Source§impl<const D: usize, T: ExtendedNumOps> Point<D, T>
impl<const D: usize, T: ExtendedNumOps> Point<D, T>
Sourcepub fn sq_dist(&self, other: &Point<D, T>) -> T
pub fn sq_dist(&self, other: &Point<D, T>) -> T
Computes the squared distance between two points.
Sourcepub fn sq_dist_origin(&self) -> T
pub fn sq_dist_origin(&self) -> T
Computes the squared distance between this point, and the origin.
Trait Implementations§
impl<const D: usize, T: Copy + ExtendedNumOps> Copy for Point<D, T>
impl<const D: usize, T: Eq + ExtendedNumOps> Eq for Point<D, T>
impl<const D: usize, T: ExtendedNumOps> StructuralPartialEq for Point<D, T>
Auto Trait Implementations§
impl<const D: usize, T> Freeze for Point<D, T>where
T: Freeze,
impl<const D: usize, T> RefUnwindSafe for Point<D, T>where
T: RefUnwindSafe,
impl<const D: usize, T> Send for Point<D, T>where
T: Send,
impl<const D: usize, T> Sync for Point<D, T>where
T: Sync,
impl<const D: usize, T> Unpin for Point<D, T>where
T: Unpin,
impl<const D: usize, T> UnwindSafe for Point<D, 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