Struct rin::graphics::Polyline [−][src]
An open or closed collection of vertices that represents a polyline or polygon
Has methods to do calculations over such geometrical shapes
Implementations
impl<T> Polyline<T> where
T: RealField + NumCast,
[src]
impl<T> Polyline<T> where
T: RealField + NumCast,
[src]pub fn new() -> Polyline<T>
[src]
creates an empty polyline
pub fn new_from_disordered_points(
points: Vec<Point<T, U2>, Global>,
closed: bool
) -> Polyline<T>
[src]
points: Vec<Point<T, U2>, Global>,
closed: bool
) -> Polyline<T>
creates a new polyline from the vector of points but orders them CCW first
pub fn area(&self) -> T
[src]
returns the area of the polygon, only works if the polyline represents a polygon
pub fn centroid(&self) -> Point<T, U2>
[src]
centroid of the polyline, should work for any collection of points although it will only make sense if it’s a polygon
pub fn close(&mut self)
[src]
mark this polyline as being a closed shape, although not necesarily a polygon. Any rendering or calculation will take into account that the first and last points are joined
pub fn is_closed(&self) -> bool
[src]
returns true if the polyline is closed
pub fn len(&self) -> usize
[src]
returns total number of points
pub fn push(&mut self, p: Point<T, U2>)
[src]
add a new point at the end of the polyline
pub fn remove(&mut self, idx: usize) -> Point<T, U2>
[src]
removes a new point at the end of the polyline
pub fn extend<I>(&mut self, vertices: I) where
I: IntoIterator<Item = Point<T, U2>>,
[src]
I: IntoIterator<Item = Point<T, U2>>,
pub fn smoothed(&self, window_size: usize, window_shape: T) -> Polyline<T>
[src]
Returns a smoothed version of the polyline.
window_size
is the size of the smoothing window. So if
window_size
is 2, then 2 points from the left, 1 in the center,
and 2 on the right (5 total) will be used for smoothing each point.
window_shape
describes whether to use a triangular window (0) or
box window (1) or something in between (for example, .5).
pub fn subdivide_linear(&self, resolution: usize) -> Polyline<T>
[src]
pub fn iter(&self) -> Iter<'_, Point<T, U2>>
[src]
pub fn iter_mut(&mut self) -> IterMut<'_, Point<T, U2>>
[src]
pub fn windows(&self, size: usize) -> Windows<'_, Point<T, U2>>
[src]
pub fn first(&self) -> Option<&Point<T, U2>>
[src]
pub fn first_mut(&mut self) -> Option<&mut Point<T, U2>>
[src]
pub fn last(&self) -> Option<&Point<T, U2>>
[src]
pub fn last_mut(&mut self) -> Option<&mut Point<T, U2>>
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn lerped_point_at(&self, fidx: T) -> Option<Point<T, U2>>
[src]
Returns the point at an index + a normalized pct
pub fn segment_length(&self, idx: usize) -> Option<T>
[src]
Returns the length of the segment at the passed index or None if such segment doesn’t exist
pub fn segment_length_squared(&self, idx: usize) -> Option<T>
[src]
Returns the square length of the segment at the passed index or None if such segment doesn’t exist
pub fn clear(&mut self)
[src]
Removes all points from the polyline
pub fn wrap_index(&self, idx: isize) -> Option<usize>
[src]
Returns an index wrapped around a closed polygon or clamped on a polyline. Will return None if the polyline is empty
pub fn next_non_zero_segment(&self, idx: usize) -> Option<usize>
[src]
Finds the next segment which length is different than 0 starting from the passed index and wrapping around on closed polygons
pub fn prev_non_zero_segment(&self, idx: usize) -> Option<usize>
[src]
Finds the previous segment which length is different than 0 starting from the passed index and wrapping around on closed polygons
pub fn simplify(&mut self, epsilon: T)
[src]
pub fn retain<F>(&mut self, f: F) where
F: FnMut(&Point<T, U2>) -> bool,
[src]
F: FnMut(&Point<T, U2>) -> bool,
impl<T> Polyline<T> where
T: NumCast + RealField,
[src]
impl<T> Polyline<T> where
T: NumCast + RealField,
[src]pub fn tangent_at(
&self,
idx: usize
) -> Option<Matrix<T, U2, U1, <DefaultAllocator as Allocator<T, U2, U1>>::Buffer>>
[src]
&self,
idx: usize
) -> Option<Matrix<T, U2, U1, <DefaultAllocator as Allocator<T, U2, U1>>::Buffer>>
Tangent at the point in the passed index if it exists
pub fn lerped_tangent_at(
&self,
fidx: T
) -> Option<Matrix<T, U2, U1, <DefaultAllocator as Allocator<T, U2, U1>>::Buffer>>
[src]
&self,
fidx: T
) -> Option<Matrix<T, U2, U1, <DefaultAllocator as Allocator<T, U2, U1>>::Buffer>>
Tangent at the lerped point at the passed index + normalized pct
Trait Implementations
impl<'de, T> Deserialize<'de> for Polyline<T> where
T: 'static + RealField + Debug + Deserialize<'de>,
[src]
impl<'de, T> Deserialize<'de> for Polyline<T> where
T: 'static + RealField + Debug + Deserialize<'de>,
[src]pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Polyline<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<Polyline<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl<T> IntoIterator for Polyline<T> where
T: RealField,
[src]
impl<T> IntoIterator for Polyline<T> where
T: RealField,
[src]impl<T> Serialize for Polyline<T> where
T: 'static + RealField + Debug + Serialize,
[src]
impl<T> Serialize for Polyline<T> where
T: 'static + RealField + Debug + Serialize,
[src]pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Auto Trait Implementations
impl<T> RefUnwindSafe for Polyline<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Polyline<T>
impl<T> Sync for Polyline<T>
impl<T> Unpin for Polyline<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Polyline<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> DowncastSync for T where
T: Any + Send + Sync,
[src]
impl<T> DowncastSync for T where
T: Any + Send + Sync,
[src]impl<T> Serialize for T where
T: Serialize + ?Sized,
[src]
impl<T> Serialize for T where
T: Serialize + ?Sized,
[src]pub fn erased_serialize(
&self,
serializer: &mut dyn Serializer
) -> Result<Ok, Error>
[src]
&self,
serializer: &mut dyn Serializer
) -> Result<Ok, Error>
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]pub fn to_subset(&self) -> Option<SS>
[src]
pub fn is_in_subset(&self) -> bool
[src]
pub fn to_subset_unchecked(&self) -> SS
[src]
pub fn from_subset(element: &SS) -> SP
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]pub fn to_subset(&self) -> Option<SS>
[src]
pub fn is_in_subset(&self) -> bool
[src]
pub fn to_subset_unchecked(&self) -> SS
[src]
pub fn from_subset(element: &SS) -> SP
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,