diff options
| -rw-r--r-- | src/math/polygon_graph.rs | 10 | ||||
| -rw-r--r-- | src/math/triangle.rs | 6 |
2 files changed, 5 insertions, 11 deletions
diff --git a/src/math/polygon_graph.rs b/src/math/polygon_graph.rs index 7721cbf..14b2b0d 100644 --- a/src/math/polygon_graph.rs +++ b/src/math/polygon_graph.rs @@ -9,7 +9,7 @@ struct Node<T: Scalar + Copy> { } struct EdgeIterator<'a, T: Scalar + Copy> { - nodes: &'a Vec<Node<T>>, + nodes: &'a [Node<T>], pos: (usize, usize), } @@ -39,7 +39,7 @@ fn find_node<T: Scalar + Copy + PartialOrd>( } impl<'a, T: Scalar + Copy> EdgeIterator<'a, T> { - pub fn new(nodes: &'a Vec<Node<T>>) -> Self { + pub fn new(nodes: &'a [Node<T>]) -> Self { Self { nodes, pos: (0, 0) } } } @@ -99,11 +99,7 @@ impl<T: Scalar + Copy + PartialOrd> PolygonGraph<T> { pub fn has_edge(&self, from: &Vec2<T>, to: &Vec2<T>) -> bool { // Binary search the starting and then the end node. if let Ok(from) = find_node(&self.nodes, from) { - if let Ok(_) = find_vec2(&self.nodes[from].adjacent, to) { - true - } else { - false - } + find_vec2(&self.nodes[from].adjacent, to).is_ok() } else { false } diff --git a/src/math/triangle.rs b/src/math/triangle.rs index 05e258d..5cf16e5 100644 --- a/src/math/triangle.rs +++ b/src/math/triangle.rs @@ -138,12 +138,10 @@ where let angle = ((ba * bc) / (ba.length() * bc.length())).acos(); // Make angle into a full circle angle by looking at the orientation of the triplet. - let angle = match orientation { + match orientation { TripletOrientation::Counterclockwise => T::pi() + (T::pi() - angle), _ => angle, - }; - - angle + } } #[cfg(test)] |
