pub struct PointList<T> {
pub points: Vec<Point<T>>,
}Fields§
§points: Vec<Point<T>>The points defining this point string.
Implementations§
Source§impl<T: Copy> PointList<T>
impl<T: Copy> PointList<T>
Sourcepub fn new<I>(i: I) -> Selfwhere
I: Into<Self>,
pub fn new<I>(i: I) -> Selfwhere
I: Into<Self>,
Create new point string by taking vertices from a type that implements Into<PointList<T>>.
Sourcepub fn edges(&self) -> impl Iterator<Item = Edge<T>> + '_
pub fn edges(&self) -> impl Iterator<Item = Edge<T>> + '_
Get the sequence of edges of the point string starting from the first point to the last.
§Examples
use reda_geometry::shape::PointList;
use reda_geometry::shape::Edge;
let coords = vec![(0, 0), (1, 0), (2, 0)];
let point_string = PointList::new(coords);
let edges: Vec<_> = point_string.edges().collect();
assert_eq!(edges, vec![Edge::new((0, 0), (1, 0)), Edge::new((1, 0), (2, 0))]);Sourcepub fn edges_reversed(&self) -> impl Iterator<Item = Edge<T>> + '_
pub fn edges_reversed(&self) -> impl Iterator<Item = Edge<T>> + '_
Same as edges but in reverse order.
Get the sequence of edges of the point string starting from the last point to the first.
§Examples
use reda_geometry::shape::PointList;
use reda_geometry::shape::Edge;
let coords = vec![(0, 0), (1, 0), (2, 0)];
let point_string = PointList::new(coords);
let edges: Vec<_> = point_string.edges_reversed().collect();
assert_eq!(edges, vec![Edge::new((2, 0), (1, 0)), Edge::new((1, 0), (0, 0))]);Source§impl<T: Copy + Sub<Output = T> + NumCast> PointList<T>
impl<T: Copy + Sub<Output = T> + NumCast> PointList<T>
Sourcepub fn path_length<F: Float>(&self) -> F
pub fn path_length<F: Float>(&self) -> F
Compute geometrical length of the path defined by the point string.
§Examples
use reda_geometry::shape::PointList;
let coords = vec![(0, 0), (1, 0), (2, 0)];
let point_string = PointList::new(coords);
assert_eq!(point_string.path_length::<f64>(), 2.0);Trait Implementations§
impl<T: Eq> Eq for PointList<T>
Source§impl<I, T, P> From<I> for PointList<T>
Create a point string from something that can be turned into an iterator of values convertible to Points.
impl<I, T, P> From<I> for PointList<T>
Create a point string from something that can be turned into an iterator of values convertible to Points.
Source§impl<T, P> FromIterator<P> for PointList<T>
Create a point string from a iterator of values convertible to Points.
impl<T, P> FromIterator<P> for PointList<T>
Create a point string from a iterator of values convertible to Points.
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = P>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = P>,
Creates a value from an iterator. Read more
impl<T: PartialEq> StructuralPartialEq for PointList<T>
Source§impl<T> TryBoundingBox<T> for PointList<T>where
T: Copy + PartialOrd,
impl<T> TryBoundingBox<T> for PointList<T>where
T: Copy + PartialOrd,
fn try_bounding_box(&self) -> Option<Rect<T>>
Auto Trait Implementations§
impl<T> Freeze for PointList<T>
impl<T> RefUnwindSafe for PointList<T>
impl<T> Send for PointList<T>
impl<T> Sync for PointList<T>
impl<T> Unpin for PointList<T>
impl<T> UnsafeUnpin for PointList<T>
impl<T> UnwindSafe for PointList<T>
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more