[−][src]Struct rin::math::Polyline
An open or closed collection of vertices that represents a polyline or polygon
Has methods to do calculations over such geometrical shapes
Methods
impl<T: Real + NumCast> Polyline<T>[src]
impl<T: Real + NumCast> Polyline<T>pub fn new() -> Polyline<T>[src]
pub fn new() -> Polyline<T>creates an empty polyline
pub fn new_from_disordered_points(
points: Vec<Pnt2<T>>,
closed: bool
) -> Polyline<T>[src]
pub fn new_from_disordered_points(
points: Vec<Pnt2<T>>,
closed: bool
) -> Polyline<T>creates a new polyline from the vector of points but orders them CCW first
pub fn area(&self) -> T[src]
pub fn area(&self) -> Treturns the area of the polygon, only works if the polyline represents a polygon
pub fn centroid(&self) -> Pnt2<T>[src]
pub fn centroid(&self) -> Pnt2<T>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]
pub fn close(&mut self)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]
pub fn is_closed(&self) -> boolreturns true if the polyline is closed
pub fn len(&self) -> usize[src]
pub fn len(&self) -> usizereturns total number of points
pub fn push(&mut self, p: Pnt2<T>)[src]
pub fn push(&mut self, p: Pnt2<T>)add a new point at the end of the polyline
pub fn smoothed(&self, window_size: usize, window_shape: T) -> Polyline<T>[src]
pub fn smoothed(&self, window_size: usize, window_shape: T) -> Polyline<T>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 subdivide_linear(&self, resolution: usize) -> Polyline<T>pub fn iter(&self) -> Iter<Pnt2<T>>[src]
pub fn iter(&self) -> Iter<Pnt2<T>>pub fn first(&self) -> Option<&Pnt2<T>>[src]
pub fn first(&self) -> Option<&Pnt2<T>>pub fn first_mut(&mut self) -> Option<&mut Pnt2<T>>[src]
pub fn first_mut(&mut self) -> Option<&mut Pnt2<T>>pub fn last(&self) -> Option<&Pnt2<T>>[src]
pub fn last(&self) -> Option<&Pnt2<T>>pub fn last_mut(&mut self) -> Option<&mut Pnt2<T>>[src]
pub fn last_mut(&mut self) -> Option<&mut Pnt2<T>>pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolpub fn lerped_point_at(&self, fidx: T) -> Option<Pnt2<T>>[src]
pub fn lerped_point_at(&self, fidx: T) -> Option<Pnt2<T>>Returns the point at an index + a normalized pct
pub fn segment_length(&self, idx: usize) -> Option<T>[src]
pub fn segment_length(&self, idx: usize) -> Option<T>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]
pub fn segment_length_squared(&self, idx: usize) -> Option<T>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]
pub fn clear(&mut self)Removes all points from the polyline
pub fn wrap_index(&self, idx: isize) -> Option<usize>[src]
pub fn wrap_index(&self, idx: isize) -> Option<usize>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]
pub fn next_non_zero_segment(&self, idx: usize) -> Option<usize>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]
pub fn prev_non_zero_segment(&self, idx: usize) -> Option<usize>Finds the previous segment which length is different than 0 starting from the passed index and wrapping around on closed polygons
impl<T: Real + NumCast + Float> Polyline<T>[src]
impl<T: Real + NumCast + Float> Polyline<T>pub fn tangent_at(&self, idx: usize) -> Option<Vec2<T>>[src]
pub fn tangent_at(&self, idx: usize) -> Option<Vec2<T>>Tangent at the point in the passed index if it exists
pub fn lerped_tangent_at(&self, fidx: T) -> Option<Vec2<T>>[src]
pub fn lerped_tangent_at(&self, fidx: T) -> Option<Vec2<T>>Tangent at the lerped point at the passed index + normalized pct
Trait Implementations
impl<T> Into<Vec<Point<T, U2>>> for Polyline<T> where
T: Real, [src]
impl<T> Into<Vec<Point<T, U2>>> for Polyline<T> where
T: Real, impl<T: Real> AsRef<[Point<T, U2>]> for Polyline<T>[src]
impl<T: Real> AsRef<[Point<T, U2>]> for Polyline<T>impl<T: Clone + Real> Clone for Polyline<T>[src]
impl<T: Clone + Real> Clone for Polyline<T>fn clone(&self) -> Polyline<T>[src]
fn clone(&self) -> Polyline<T>fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<T: Real> IntoIterator for Polyline<T>[src]
impl<T: Real> IntoIterator for Polyline<T>type Item = Pnt2<T>
The type of the elements being iterated over.
type IntoIter = IntoIter<Pnt2<T>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IntoIter<Pnt2<T>>[src]
fn into_iter(self) -> IntoIter<Pnt2<T>>impl<T: Debug + Real> Debug for Polyline<T>[src]
impl<T: Debug + Real> Debug for Polyline<T>impl<T: Real> Index<usize> for Polyline<T>[src]
impl<T: Real> Index<usize> for Polyline<T>type Output = Pnt2<T>
The returned type after indexing.
fn index(&self, idx: usize) -> &Pnt2<T>[src]
fn index(&self, idx: usize) -> &Pnt2<T>impl<T: Real> IndexMut<usize> for Polyline<T>[src]
impl<T: Real> IndexMut<usize> for Polyline<T>impl<T> FromIterator<Point<T, U2>> for Polyline<T> where
T: Real, [src]
impl<T> FromIterator<Point<T, U2>> for Polyline<T> where
T: Real, fn from_iter<I>(iter: I) -> Polyline<T> where
I: IntoIterator<Item = Pnt2<T>>, [src]
fn from_iter<I>(iter: I) -> Polyline<T> where
I: IntoIterator<Item = Pnt2<T>>, impl<T: Real> Serialize for Polyline<T> where
T: Serialize, [src]
impl<T: Real> Serialize for Polyline<T> where
T: Serialize, fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, impl<'de, T: Real> Deserialize<'de> for Polyline<T> where
T: Deserialize<'de>, [src]
impl<'de, T: Real> Deserialize<'de> for Polyline<T> where
T: Deserialize<'de>, fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, impl<T> From for T[src]
impl<T> From for Timpl<I> IntoIterator for I where
I: Iterator, [src]
impl<I> IntoIterator for I where
I: Iterator, type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I[src]
fn into_iter(self) -> Iimpl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeIdimpl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut Timpl<T> Any for T where
T: Any, [src]
impl<T> Any for T where
T: Any, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeIdimpl<T> SetParameter for T[src]
impl<T> SetParameter for Tfn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>, [src]
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>, Sets value as a parameter of self.
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, [src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, impl<V> IntoVec for V[src]
impl<V> IntoVec for Vimpl<V> IntoPnt for V[src]
impl<V> IntoPnt for Vimpl<T> Same for T[src]
impl<T> Same for Ttype Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>, [src]
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>, fn to_subset(&self) -> Option<SS>[src]
fn to_subset(&self) -> Option<SS>fn is_in_subset(&self) -> bool[src]
fn is_in_subset(&self) -> boolunsafe fn to_subset_unchecked(&self) -> SS[src]
unsafe fn to_subset_unchecked(&self) -> SSfn from_subset(element: &SS) -> SP[src]
fn from_subset(element: &SS) -> SP