diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/math/mod.rs | 4 | ||||
| -rw-r--r-- | src/math/polygon/mod.rs (renamed from src/math/polygon.rs) | 10 | ||||
| -rw-r--r-- | src/math/polygon/polygon_graph.rs (renamed from src/math/polygon_graph.rs) | 7 | ||||
| -rw-r--r-- | src/math/polygon/triangulate.rs (renamed from src/math/triangulate.rs) | 3 |
4 files changed, 15 insertions, 9 deletions
diff --git a/src/math/mod.rs b/src/math/mod.rs index 07bc36b..e72a7a4 100644 --- a/src/math/mod.rs +++ b/src/math/mod.rs @@ -1,17 +1,13 @@ pub mod line_segment; pub mod polygon; -pub mod polygon_graph; pub mod rect; pub mod triangle; -pub mod triangulate; pub mod vec2; pub use self::line_segment::*; pub use self::polygon::*; -pub use self::polygon_graph::*; pub use self::rect::*; pub use self::triangle::*; -pub use self::triangulate::*; pub use self::vec2::*; use std::cmp::Ordering; diff --git a/src/math/polygon.rs b/src/math/polygon/mod.rs index 5711049..4530857 100644 --- a/src/math/polygon.rs +++ b/src/math/polygon/mod.rs @@ -1,4 +1,12 @@ -use super::{PolygonGraph, Vec2}; +//! Contains functions and structures to help with operations on polygons. + +pub mod polygon_graph; +pub mod triangulate; + +pub use polygon_graph::*; +pub use triangulate::*; + +use super::Vec2; use nalgebra::{ClosedDiv, ClosedMul, ClosedSub, RealField, Scalar}; use num_traits::Zero; use std::ops::Neg; diff --git a/src/math/polygon_graph.rs b/src/math/polygon/polygon_graph.rs index 14b2b0d..9477fbc 100644 --- a/src/math/polygon_graph.rs +++ b/src/math/polygon/polygon_graph.rs @@ -1,4 +1,5 @@ -use super::{LineSegment, Polygon, Vec2}; +use super::Polygon; +use crate::math::{self, LineSegment, Vec2}; use nalgebra::{RealField, Scalar}; use std::cmp::{Ordering, PartialOrd}; @@ -273,8 +274,8 @@ impl<T: Scalar + Copy + PartialOrd> PolygonGraph<T> { .adjacent .iter() .max_by(|&a, &b| { - super::triplet_angle(last_vec, current_node.vec, *a) - .partial_cmp(&super::triplet_angle(last_vec, current_node.vec, *b)) + math::triplet_angle(last_vec, current_node.vec, *a) + .partial_cmp(&math::triplet_angle(last_vec, current_node.vec, *b)) .unwrap_or(Ordering::Equal) }) .expect("Adjacency list is empty. The polygon has an open edge (is broken)"); diff --git a/src/math/triangulate.rs b/src/math/polygon/triangulate.rs index 8ef92f1..4860518 100644 --- a/src/math/triangulate.rs +++ b/src/math/polygon/triangulate.rs @@ -1,6 +1,7 @@ //! Module for turning a polygon into a number of non-overlapping triangles. -use super::{Polygon, Triangle}; +use super::Polygon; +use crate::math::Triangle; use nalgebra::Scalar; /// Uses earclipping algorithm (see https://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf) |
