Struct libreda_db::prelude::PointString[][src]

pub struct PointString<T> where
    T: CoordinateType
{ pub points: Vec<Point<T>, Global>, }

A point string is a finite sequence of points. TODO: Implement Deref for accessing the list of points.

Fields

points: Vec<Point<T>, Global>

The points defining this point string.

Implementations

impl<T> PointString<T> where
    T: CoordinateType
[src]

pub fn new<I>(i: I) -> PointString<T> where
    I: Into<PointString<T>>, 
[src]

Create new point string by taking vertices from a type that implements Into<PointString<T>>.

pub fn len(&self) -> usize[src]

Get the number of vertices.

pub fn iter(&self) -> Iter<'_, Point<T>>[src]

Shortcut for self.points.iter().

pub fn edges(&self) -> impl Iterator<Item = Edge<T>>[src]

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))]);

pub fn edges_reversed(&self) -> impl Iterator<Item = Edge<T>>[src]

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))]);

impl<T> PointString<T> where
    T: CoordinateType + NumCast
[src]

pub fn path_length<F>(&self) -> F where
    F: Float
[src]

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

impl<T> Clone for PointString<T> where
    T: CoordinateType + Clone
[src]

impl<T> Debug for PointString<T> where
    T: CoordinateType + Debug
[src]

impl<T> Eq for PointString<T> where
    T: CoordinateType + Eq
[src]

impl<I, T, P> From<I> for PointString<T> where
    T: CoordinateType,
    I: IntoIterator<Item = P>,
    Point<T>: From<P>, 
[src]

Create a point string from something that can be turned into an iterator of values convertible to Points.

impl<T, P> FromIterator<P> for PointString<T> where
    T: CoordinateType,
    P: Into<Point<T>>, 
[src]

Create a point string from a iterator of values convertible to Points.

impl<T> Hash for PointString<T> where
    T: CoordinateType + Hash
[src]

impl<T> MapPointwise<T> for PointString<T> where
    T: CoordinateType
[src]

impl<T> PartialEq<PointString<T>> for PointString<T> where
    T: CoordinateType + PartialEq<T>, 
[src]

impl<T> StructuralEq for PointString<T> where
    T: CoordinateType
[src]

impl<T> StructuralPartialEq for PointString<T> where
    T: CoordinateType
[src]

impl<T> TryBoundingBox<T> for PointString<T> where
    T: CoordinateType
[src]

pub fn try_bounding_box(&self) -> Option<Rect<T>>[src]

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))));

impl<T, Dst> TryCastCoord<T, Dst> for PointString<T> where
    T: CoordinateType + NumCast,
    Dst: CoordinateType + NumCast
[src]

type Output = PointString<Dst>

Output type of the cast. This is likely the same geometrical type just with other coordinate types. Read more

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<S, T> Mirror<T> for S where
    S: MapPointwise<T>,
    T: CoordinateType
[src]

pub fn mirror_x(&self) -> S[src]

Return the geometrical object mirrored at the x axis.

pub fn mirror_y(&self) -> S[src]

Return the geometrical object mirrored at the y axis.

impl<S, T> RotateOrtho<T> for S where
    S: MapPointwise<T>,
    T: CoordinateType
[src]

impl<S, T> Scale<T> for S where
    S: MapPointwise<T>,
    T: CoordinateType
[src]

impl<T> TextType for T where
    T: Clone + Eq + Debug + Hash
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<S, T> Translate<T> for S where
    S: MapPointwise<T>,
    T: CoordinateType
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.