From e01e14d4dacda37bb736ced5074dffca352dfd09 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 9 Apr 2022 15:20:12 +0200 Subject: [PATCH 1/2] Add `PolyChain::new` --- fj-math/src/poly_chain.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fj-math/src/poly_chain.rs b/fj-math/src/poly_chain.rs index 8f566cb58..f9726384e 100644 --- a/fj-math/src/poly_chain.rs +++ b/fj-math/src/poly_chain.rs @@ -11,6 +11,11 @@ pub struct PolyChain { } impl PolyChain { + /// Create an empty `PolyChain` + pub fn new() -> Self { + Self { points: Vec::new() } + } + /// Construct a polygonal chain from a number of points pub fn from_points( points: impl IntoIterator>>, @@ -48,6 +53,12 @@ impl PolyChain { } } +impl Default for PolyChain { + fn default() -> Self { + Self::new() + } +} + impl From for PolyChain where P: Into>, From 17b8b91f63a6c614f0a0ca10991edee6f52ca3d4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 9 Apr 2022 15:24:38 +0200 Subject: [PATCH 2/2] Add `PolyChain::reverse` --- fj-math/src/poly_chain.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fj-math/src/poly_chain.rs b/fj-math/src/poly_chain.rs index f9726384e..0c762226d 100644 --- a/fj-math/src/poly_chain.rs +++ b/fj-math/src/poly_chain.rs @@ -51,6 +51,12 @@ impl PolyChain { self } + + /// Reverse the order of points in the `PolyChain` + pub fn reverse(mut self) -> Self { + self.points.reverse(); + self + } } impl Default for PolyChain {