pub struct PointString<T> {
pub points: Vec<Point<T>>,
}
Expand description
A point string is a finite sequence of points.
TODO: Implement Deref
for accessing the list of points.
Fields§
§points: Vec<Point<T>>
The points defining this point string.
Implementations§
Source§impl<T> PointString<T>
impl<T> PointString<T>
Source§impl<T> PointString<T>where
T: Copy,
impl<T> PointString<T>where
T: Copy,
Sourcepub fn new<I>(i: I) -> PointString<T>where
I: Into<PointString<T>>,
pub fn new<I>(i: I) -> PointString<T>where
I: Into<PointString<T>>,
Create new point string by taking vertices from a type that implements Into<PointString<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 iron_shapes::point_string::PointString;
use iron_shapes::edge::Edge;
let coords = vec![(0, 0), (1, 0), (2, 0)];
let point_string = PointString::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 iron_shapes::point_string::PointString;
use iron_shapes::edge::Edge;
let coords = vec![(0, 0), (1, 0), (2, 0)];
let point_string = PointString::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> PointString<T>
impl<T> PointString<T>
Sourcepub fn path_length<F>(&self) -> Fwhere
F: Float,
pub fn path_length<F>(&self) -> Fwhere
F: Float,
Compute geometrical length of the path defined by the point string.
§Examples
use iron_shapes::point_string::PointString;
let coords = vec![(0, 0), (1, 0), (2, 0)];
let point_string = PointString::new(coords);
assert_eq!(point_string.path_length::<f64>(), 2.0);
Trait Implementations§
Source§impl<T> Clone for PointString<T>where
T: Clone,
impl<T> Clone for PointString<T>where
T: Clone,
Source§fn clone(&self) -> PointString<T>
fn clone(&self) -> PointString<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> Debug for PointString<T>where
T: Debug,
impl<T> Debug for PointString<T>where
T: Debug,
Source§impl<'de, T> Deserialize<'de> for PointString<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for PointString<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PointString<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PointString<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<I, T, P> From<I> for PointString<T>
Create a point string from something that can be turned into an iterator of values convertible to Point
s.
impl<I, T, P> From<I> for PointString<T>
Create a point string from something that can be turned into an iterator of values convertible to Point
s.
Source§fn from(iter: I) -> PointString<T>
fn from(iter: I) -> PointString<T>
Source§impl<T, P> FromIterator<P> for PointString<T>
Create a point string from a iterator of values convertible to Point
s.
impl<T, P> FromIterator<P> for PointString<T>
Create a point string from a iterator of values convertible to Point
s.
Source§fn from_iter<I>(iter: I) -> PointString<T>where
I: IntoIterator<Item = P>,
fn from_iter<I>(iter: I) -> PointString<T>where
I: IntoIterator<Item = P>,
Source§impl<T> Hash for PointString<T>where
T: Hash,
impl<T> Hash for PointString<T>where
T: Hash,
Source§impl<T> MapPointwise<T> for PointString<T>where
T: Copy,
impl<T> MapPointwise<T> for PointString<T>where
T: Copy,
Source§impl<T> PartialEq for PointString<T>where
T: PartialEq,
impl<T> PartialEq for PointString<T>where
T: PartialEq,
Source§impl<T> Serialize for PointString<T>where
T: Serialize,
impl<T> Serialize for PointString<T>where
T: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl<T> TryBoundingBox<T> for PointString<T>where
T: Copy + PartialOrd,
impl<T> TryBoundingBox<T> for PointString<T>where
T: Copy + PartialOrd,
Source§fn try_bounding_box(&self) -> Option<Rect<T>>
fn try_bounding_box(&self) -> Option<Rect<T>>
Compute the bounding box of all the points in this string.
Returns None
if the string is empty.
§Examples
use iron_shapes::point_string::PointString;
use iron_shapes::traits::TryBoundingBox;
use iron_shapes::rect::Rect;
let coords = vec![(0, 0), (1, 0), (2, 1), (-1, -3)];
let point_string = PointString::new(coords);
assert_eq!(point_string.try_bounding_box(), Some(Rect::new((2, 1), (-1, -3))));
Source§impl<T, Dst> TryCastCoord<T, Dst> for PointString<T>
impl<T, Dst> TryCastCoord<T, Dst> for PointString<T>
Source§type Output = PointString<Dst>
type Output = PointString<Dst>
Source§fn try_cast(&self) -> Option<<PointString<T> as TryCastCoord<T, Dst>>::Output>
fn try_cast(&self) -> Option<<PointString<T> as TryCastCoord<T, Dst>>::Output>
impl<T> Eq for PointString<T>where
T: Eq,
impl<T> StructuralPartialEq for PointString<T>
Auto Trait Implementations§
impl<T> Freeze for PointString<T>
impl<T> RefUnwindSafe for PointString<T>where
T: RefUnwindSafe,
impl<T> Send for PointString<T>where
T: Send,
impl<T> Sync for PointString<T>where
T: Sync,
impl<T> Unpin for PointString<T>where
T: Unpin,
impl<T> UnwindSafe for PointString<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
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>
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>
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