Add PolyChain::new

This commit is contained in:
Hanno Braun 2022-04-09 15:20:12 +02:00
parent 0b445e2a89
commit e01e14d4da

View File

@ -11,6 +11,11 @@ pub struct PolyChain<const D: usize> {
} }
impl<const D: usize> PolyChain<D> { impl<const D: usize> PolyChain<D> {
/// Create an empty `PolyChain`
pub fn new() -> Self {
Self { points: Vec::new() }
}
/// Construct a polygonal chain from a number of points /// Construct a polygonal chain from a number of points
pub fn from_points( pub fn from_points(
points: impl IntoIterator<Item = impl Into<Point<D>>>, points: impl IntoIterator<Item = impl Into<Point<D>>>,
@ -48,6 +53,12 @@ impl<const D: usize> PolyChain<D> {
} }
} }
impl<const D: usize> Default for PolyChain<D> {
fn default() -> Self {
Self::new()
}
}
impl<P, Ps, const D: usize> From<Ps> for PolyChain<D> impl<P, Ps, const D: usize> From<Ps> for PolyChain<D>
where where
P: Into<Point<D>>, P: Into<Point<D>>,