diff --git a/.gitignore b/.gitignore index c220dcf..565e7c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target /Cargo.lock -.vscode \ No newline at end of file +.vscode +.idea \ No newline at end of file diff --git a/Architecture.md b/Architecture.md index 25a6e87..ef0e93a 100644 --- a/Architecture.md +++ b/Architecture.md @@ -40,7 +40,7 @@ Trait `Triangulation` contains *publicly visible* functions that are common for `DCEL` (in `dcel.rs`) implements the underlying doubly connected edge list and all of its major accessor methods (e.g., for accessing vertices, edges and faces). `dcel_operations.rs` implements several common operations on a DCEL, e.g. flipping an edge. -`DCEL`, and `dcel_operations` should, in contrast to `Triangulation`, not require a `V: HasPosition` bound anywhere. In other words: DCEL's only care about the *topology* of their elements, not about their actual position. The position is only required once the Delaunay property is evaluated (as part of `TriangulationExt`) +`DCEL`, and `dcel_operations` should, in contrast to `Triangulation`, not require a `V: HasPosition` bound anywhere. In other words: DCELs only care about the *topology* of their elements, not about their actual position. The position is only required once the Delaunay property is evaluated (as part of `TriangulationExt`) # Module dependency graph diff --git a/CHANGELOG.md b/CHANGELOG.md index d5710c0..d095d55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -213,7 +213,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [1.2.0] - 2017-05-13 ### Changed - Bumped compatible `cgmath` and `nalgebra` versions. Unfortunately, due to the way Cargo handles "external dependencies" (thus, dependencies whose types are part of spade's public API like `cgmath` and `nalgebra` Points), this must be considered a breaking change. - - `FloatKernel` now works happily with `f32` coordinates. They will be casted to double precision before the kernel evaluates any query, thus, no performance gain results from this. Only the space requirements will differ. + - `FloatKernel` now works happily with `f32` coordinates. They will be cast to double precision before the kernel evaluates any query, thus, no performance gain results from this. Only the space requirements will differ. ## [1.1.0] - 2017-04-12 ### Deprecated @@ -313,9 +313,8 @@ A lot has changed for the 1.0. release, only larger changes are shown. ### Changed - cgmath dependency bumped to 0.12.* - - DelaunayTriangulations and some primitives now will only work with two - dimensional coordinates. Using higher dimensions actually yielded unspecified - results. + - DelaunayTriangulations and some primitives now will only work with two-dimensional + coordinates. Using higher dimensions actually yielded unspecified results. ## 0.1.0 - 2016-09-23 Initial commit diff --git a/delaunay_compare/examples/real_data_benchmark.rs b/delaunay_compare/examples/real_data_benchmark.rs index 1c4b346..21b174f 100644 --- a/delaunay_compare/examples/real_data_benchmark.rs +++ b/delaunay_compare/examples/real_data_benchmark.rs @@ -2,7 +2,7 @@ use std::time::Instant; use anyhow::{Context, Ok}; use spade::{ConstrainedDelaunayTriangulation, Point2, Triangulation}; -use tiny_skia::{Color, Paint, PathBuilder, Pixmap, Stroke, Transform}; +use tiny_skia::{Paint, PathBuilder, Pixmap, Stroke, Transform}; fn main() -> anyhow::Result<()> { let shape_file_path = "./examples/Europe_coastline.shp"; @@ -51,8 +51,7 @@ fn load_with_spade(vertices: &Vec>, edges: &Vec<[usize; 2]>) -> anyh println!("Loading triangulation (spade)..."); let now = Instant::now(); - let cdt = - spade::ConstrainedDelaunayTriangulation::<_>::bulk_load_cdt(vertices_clone, edges_clone)?; + let cdt = ConstrainedDelaunayTriangulation::<_>::bulk_load_cdt(vertices_clone, edges_clone)?; println!("Done!"); println!("{} vertices (without duplicates)", cdt.num_vertices()); println!("{} undirected edges", cdt.num_undirected_edges()); @@ -69,10 +68,7 @@ fn load_with_spade(vertices: &Vec>, edges: &Vec<[usize; 2]>) -> anyh let edges_clone = edges.clone(); let now = Instant::now(); - spade::ConstrainedDelaunayTriangulation::<_>::bulk_load_cdt_stable( - vertices_clone, - edges_clone, - )?; + ConstrainedDelaunayTriangulation::<_>::bulk_load_cdt_stable(vertices_clone, edges_clone)?; println!( "loading time (spade cdt bulk load stable): {}ms", @@ -82,7 +78,7 @@ fn load_with_spade(vertices: &Vec>, edges: &Vec<[usize; 2]>) -> anyh let vertices_clone = vertices.clone(); let now = Instant::now(); - spade::ConstrainedDelaunayTriangulation::<_>::bulk_load(vertices_clone)?; + ConstrainedDelaunayTriangulation::<_>::bulk_load(vertices_clone)?; println!( "loading time (spade without constraints): {}ms", now.elapsed().as_millis() diff --git a/examples/interpolation/main.rs b/examples/interpolation/main.rs index 1fc9526..d9b7b3f 100644 --- a/examples/interpolation/main.rs +++ b/examples/interpolation/main.rs @@ -52,7 +52,7 @@ const VERTICES: &[PointWithHeight] = &[ PointWithHeight::new(5.0, 1.0, 0.2), ]; -pub fn main() -> anyhow::Result<()> { +pub fn main() -> Result<()> { let mut t = TriangulationType::default(); for vertex in VERTICES { t.insert(*vertex)?; @@ -146,7 +146,7 @@ pub fn main() -> anyhow::Result<()> { ); } - fn save_pixmap(pixmap: Pixmap, name: &str) -> anyhow::Result<()> { + fn save_pixmap(pixmap: Pixmap, name: &str) -> Result<()> { // tiny_skia doesn't support jpg encoding which is required for small file size when embedding this into // the documentation. We'll have to convert the data into ImageBuffer from the image crate and then do // the jpeg encoding. @@ -176,7 +176,7 @@ pub fn main() -> anyhow::Result<()> { } fn float_to_color(value: f64) -> [u8; 3] { - // mostly AI generated.. + // mostly AI generated... // Converts a hue value in the range 0.0 ..= 1.0 from HLS to RGB let value = value.clamp(0.0, 1.0); diff --git a/examples/svg_renderer/scenario_list.rs b/examples/svg_renderer/scenario_list.rs index 21fc5bb..f87c095 100644 --- a/examples/svg_renderer/scenario_list.rs +++ b/examples/svg_renderer/scenario_list.rs @@ -410,7 +410,7 @@ pub fn delaunay_directed_edge_details_scenario() -> Sketch { sketch.add(rev_label); - let next = edge.prev(); // Use prev since SVG uses a left handed coordinate system + let next = edge.prev(); // Use prev since SVG uses a left-handed coordinate system let next_label = SketchElement::line(from_pos, convert_point(next.from().position())) .create_adjacent_text("e.next()") .font_size(FONT_SIZE) @@ -418,7 +418,7 @@ pub fn delaunay_directed_edge_details_scenario() -> Sketch { sketch.add(next_label); - let prev = edge.next(); // Use prev since SVG uses a left handed coordinate system + let prev = edge.next(); // Use prev since SVG uses a left-handed coordinate system let prev_label = SketchElement::line(convert_point(prev.to().position()), to_pos) .create_adjacent_text("e.prev()") .font_size(FONT_SIZE) diff --git a/images/preview.html b/images/preview.html index d91ea2f..c48bb8c 100644 --- a/images/preview.html +++ b/images/preview.html @@ -2,10 +2,10 @@ - +preview image \ No newline at end of file diff --git a/src/cdt.rs b/src/cdt.rs index 774ddf9..867a368 100644 --- a/src/cdt.rs +++ b/src/cdt.rs @@ -69,7 +69,7 @@ impl AsMut for CdtEdge { } } -/// A two dimensional +/// A two-dimensional /// [constrained Delaunay triangulation](https://en.wikipedia.org/wiki/Constrained_Delaunay_triangulation). /// /// A constrained Delaunay triangulation (CDT) is a triangulation that @@ -124,7 +124,7 @@ impl AsMut for CdtEdge { /// /// # See also /// Refer to [Triangulation] for most implemented methods on this type. -/// Refer to [DelaunayTriangulation](crate::DelaunayTriangulation) for general +/// Refer to [DelaunayTriangulation](DelaunayTriangulation) for general /// information about using Delaunay triangulations. #[doc(alias = "CDT")] #[derive(Clone)] @@ -213,13 +213,6 @@ where &mut self.hint_generator } - fn clear(&mut self) { - self.num_constraints = 0; - self.s_mut().clear(); - let new_hint_generator = HintGenerator::initialize_from_triangulation(self); - *self.hint_generator_mut() = new_hint_generator; - } - fn from_parts( dcel: Dcel, hint_generator: Self::HintGenerator, @@ -241,6 +234,13 @@ where ) { (self.dcel, self.hint_generator, self.num_constraints) } + + fn clear(&mut self) { + self.num_constraints = 0; + self.s_mut().clear(); + let new_hint_generator = HintGenerator::initialize_from_triangulation(self); + *self.hint_generator_mut() = new_hint_generator; + } } impl From> @@ -308,6 +308,7 @@ where /// ``` /// /// # Panics + /// /// Panics if any constraint edges overlap. Panics if the edges contain an invalid index (out of range). pub fn bulk_load_cdt(vertices: Vec, edges: Vec<[usize; 2]>) -> Result { let mut result = bulk_load_cdt(vertices, edges)?; @@ -479,6 +480,7 @@ where /// ``` /// /// # Panics + /// /// Panics if any of the generated constraints intersects with any other constraint edge. pub fn add_constraint_edges( &mut self, @@ -509,6 +511,7 @@ where /// Returns `true` if at least one constraint edge was added. /// /// # Panics + /// /// Panics if the new constraint edge intersects with an existing /// constraint edge. Use [can_add_constraint](Self::can_add_constraint) to check. pub fn add_constraint_edge(&mut self, from: V, to: V) -> Result { @@ -520,7 +523,7 @@ where /// Adds a constraint edge between to vertices. /// /// Returns `true` if at least one constraint edge was added. - /// Note that the given constraint might be splitted into smaller edges + /// Note that the given constraint might be split into smaller edges /// if a vertex in the triangulation lies exactly on the constraint edge. /// Thus, `cdt.exists_constraint(from, to)` is not necessarily `true` /// after a call to this function. @@ -528,6 +531,7 @@ where /// Returns false and does nothing if `from == to`. /// /// # Panics + /// /// Panics if the new constraint edge intersects an existing /// constraint edge. pub fn add_constraint(&mut self, from: FixedVertexHandle, to: FixedVertexHandle) -> bool { @@ -625,7 +629,7 @@ where let border_loop_vec: Vec<_> = border_loop.into(); // The last edge of border_loop_vec must be part of the added constraint - // edge. Otherwise remesh_edge_ring will not create an edge between + // edge. Otherwise, remesh_edge_ring will not create an edge between // cur_from and vertex assert_eq!( self.directed_edge(*border_loop_vec.last().unwrap()) @@ -926,7 +930,7 @@ mod test { fn test_add_border_constraint() -> Result<(), InsertionError> { let points = random_points_with_seed(1000, SEED); let mut cdt = Cdt::new(); - let mut max_y = -::core::f64::MAX; + let mut max_y = -f64::MAX; for point in points { max_y = max_y.max(point.y); cdt.insert(point)?; @@ -959,12 +963,12 @@ mod test { } let seed = if overlapping { SEED } else { SEED2 }; let delaunay_points = random_points_in_range(RANGE * 0.9, 80, seed); - // Use a delaunay triangulation to "generate" non intersecting constraint edges + // Use a delaunay triangulation to "generate" non-intersecting constraint edges let mut d = Delaunay::new(); for p in delaunay_points { d.insert(p)?; } - let mut used_vertices = ::hashbrown::HashSet::new(); + let mut used_vertices = hashbrown::HashSet::new(); let mut inserted_constraints = Vec::new(); for v in d.vertices() { @@ -1159,7 +1163,7 @@ mod test { fn fuzz_test_on_grid() -> Result<(), InsertionError> { use rand::seq::SliceRandom; // Generates points on a grid and randomly connects - // them with non intersecting constraints + // them with non-intersecting constraints let seed = SEED; let mut points = Vec::with_capacity((RANGE * RANGE) as usize); const RANGE: i64 = 30; diff --git a/src/delaunay_core/bulk_load.rs b/src/delaunay_core/bulk_load.rs index 139ea90..1fade0e 100644 --- a/src/delaunay_core/bulk_load.rs +++ b/src/delaunay_core/bulk_load.rs @@ -16,7 +16,7 @@ use alloc::vec::Vec; /// /// This is only used as part of bulk loading. /// All input coordinates are checked with `validate_coordinate` before they are used, hence -/// `Ord` and `Eq` should always be well defined. +/// `Ord` and `Eq` should always be well-defined. #[derive(Debug, PartialEq, PartialOrd, Clone, Copy)] struct FloatOrd(S); @@ -277,7 +277,7 @@ where // // This process is certainly confusing and inefficient but, luckily, rarely required for real inputs. - // Push the element again, it will popped directly. This seems to be somewhat simpler than + // Push the element again, it will be popped directly. This seems to be somewhat simpler than // the alternatives. elements.push((old_index, skipped)); hull = loop { @@ -327,7 +327,7 @@ where // Note that we don't re-sort the elements according to their distance to the newest center. This doesn't seem to // be required for the algorithms performance, probably due to the `center` being close to `initial_center`. - // As of now, it is a unclear how to construct point sets that result in a `center` being farther off + // As of now, it is unclear how to construct point sets that result in a `center` being farther off // `initial center` and what the impact of this would be. let center = Point2::new(sum_x, sum_y).mul(::Scalar::from(0.25f32)); @@ -484,7 +484,7 @@ where let edge = edge.fix(); let new_vertex = - super::dcel_operations::create_new_face_adjacent_to_edge(result.s_mut(), edge, element); + dcel_operations::create_new_face_adjacent_to_edge(result.s_mut(), edge, element); let ccw_walk_start = result.directed_edge(edge).prev().rev().fix(); let cw_walk_start = result.directed_edge(edge).next().rev().fix(); @@ -495,7 +495,7 @@ where // up in a strongly *star shaped* triangulation instead of a nice nearly-convex blob of faces. // // To fix this, the algorithm proceeds by connecting some of the adjacent edges and forming new - // faces. A faces is only created if all of its inner angles are less than 90 degrees. This + // faces. A face is only created if all of its inner angles are less than 90 degrees. This // tends to be a good heuristic that doesn't create too many skewed triangles which would need // to be fixed later. Refer to the motivating research paper (see method `bulk_load`) for // more information. @@ -707,10 +707,10 @@ struct Node { /// It implements an efficient mapping of (pseudo-)angles to edges. To do so, it stores all inserted /// edges in a linked list backed by a vec. Finding an edge belonging to a given angle can always /// be done by iterating through this list until the target angle is found. -/// The entries are stored in a consistent order (either clockwise or counter clockwise) +/// The entries are stored in a consistent order (either clockwise or counterclockwise) /// /// This naive sequential search is very slow as it needs to traverse half of the list on average. -/// To speed things up, the space space of valid angles (the half open interval [0, 1) ) +/// To speed things up, the space of valid angles (the half open interval [0, 1) ) /// is partitioned into `n` equally sized buckets. /// For each bucket, `Hull` stores a reference to the list entry with the *biggest angle* that /// still belongs into that bucket. A sequential search will begin at this bucket and has to traverse @@ -825,7 +825,7 @@ impl Hull { /// Such a vertex is guaranteed to have two outgoing edges that are adjacent to the convex hull, /// e.g. `e0 -> v -> e1` /// - /// In this scenarios, the parameters should be set as follows: + /// In these scenarios, the parameters should be set as follows: /// * `left_angle`: `pseudo_angle(e0.from())` /// * `middle_angle`: `pseudo_angle(v.position())` /// * `right_angle`: `pseudo_angle(e1.to())` @@ -896,7 +896,7 @@ impl Hull { right_angle = self.data[right_index].angle; } - // Stich the vertex between left_index and right_index + // Stitch the vertex between left_index and right_index self.data[left_index].right = new_index; self.data[right_index].left = new_index; @@ -970,11 +970,11 @@ impl Hull { /// Looks up what bucket a given pseudo-angle will fall into. fn floored_bucket(&self, angle: FloatOrd) -> usize { - ((angle.0 * (self.buckets.len()) as f64).floor() as usize) % self.buckets.len() + ((angle.0 * self.buckets.len() as f64).floor() as usize) % self.buckets.len() } fn ceiled_bucket(&self, angle: FloatOrd) -> usize { - ((angle.0 * (self.buckets.len()) as f64).ceil() as usize) % self.buckets.len() + ((angle.0 * self.buckets.len() as f64).ceil() as usize) % self.buckets.len() } fn segment(&self, node: &Node) -> Segment { diff --git a/src/delaunay_core/dcel_operations.rs b/src/delaunay_core/dcel_operations.rs index 3c56542..b671509 100644 --- a/src/delaunay_core/dcel_operations.rs +++ b/src/delaunay_core/dcel_operations.rs @@ -906,7 +906,7 @@ where UE: Default, F: Default, { - // All edges are oriented counter clockwise + // All edges are oriented counterclockwise // // Original triangle: // v1 diff --git a/src/delaunay_core/handles/handle_defs.rs b/src/delaunay_core/handles/handle_defs.rs index b68f72b..4fb6df0 100644 --- a/src/delaunay_core/handles/handle_defs.rs +++ b/src/delaunay_core/handles/handle_defs.rs @@ -12,7 +12,7 @@ pub trait DelaunayElementType: Sized + Default { } /// Internal type definition that is only exposed for documentation purposes. /// -/// Rust will currently not generate documentation for type definitions depending +/// Rust will currently not generate documentation for type definitions depending on /// `pub(crate)` types, see [#32077](https://github.com/rust-lang/rust/issues/32077). /// /// Do not use these types. Their removal will not be considered a breaking change. @@ -105,7 +105,7 @@ impl FixedHandleImpl core::fmt::Debug for VertexHandle<'a, V, DE, UE, F> { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { +impl<'a, V, DE, UE, F> Debug for VertexHandle<'a, V, DE, UE, F> { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "VertexHandle({:?})", self.handle.index()) } } impl<'a, V, DE, UE, F> Debug for DirectedEdgeHandle<'a, V, DE, UE, F> { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!( f, "DirectedEdgeHandle - id: {:?} ({:?} -> {:?})", @@ -30,8 +30,8 @@ impl<'a, V, DE, UE, F> Debug for DirectedEdgeHandle<'a, V, DE, UE, F> { } } -impl<'a, V, DE, UE, F> core::fmt::Debug for UndirectedEdgeHandle<'a, V, DE, UE, F> { - fn fmt(&self, f: &mut core::fmt::Formatter) -> ::core::fmt::Result { +impl<'a, V, DE, UE, F> Debug for UndirectedEdgeHandle<'a, V, DE, UE, F> { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { let [v0, v1] = self.vertices(); write!( f, @@ -43,8 +43,8 @@ impl<'a, V, DE, UE, F> core::fmt::Debug for UndirectedEdgeHandle<'a, V, DE, UE, } } -impl<'a, V, DE, UE, F> core::fmt::Debug for FaceHandle<'a, PossiblyOuterTag, V, DE, UE, F> { - fn fmt(&self, f: &mut core::fmt::Formatter) -> ::core::fmt::Result { +impl<'a, V, DE, UE, F> Debug for FaceHandle<'a, PossiblyOuterTag, V, DE, UE, F> { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(inner) = self.as_inner() { inner.fmt(f) } else { @@ -53,8 +53,8 @@ impl<'a, V, DE, UE, F> core::fmt::Debug for FaceHandle<'a, PossiblyOuterTag, V, } } -impl<'a, V, DE, UE, F> core::fmt::Debug for FaceHandle<'a, InnerTag, V, DE, UE, F> { - fn fmt(&self, f: &mut core::fmt::Formatter) -> ::core::fmt::Result { +impl<'a, V, DE, UE, F> Debug for FaceHandle<'a, InnerTag, V, DE, UE, F> { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { let [v0, v1, v2] = self.vertices(); write!( f, @@ -76,7 +76,7 @@ impl FixedDirectedEdgeHandle { /// Returns if this edge is the normalized edge of a directed edge pair. /// /// For every directed edge pair, one edge is marked as the normalized edge. This information - /// is used to hook up a directed edge handle with it's correct half edge storage. + /// is used to hook up a directed edge handle with its correct half edge storage. #[inline] pub(in super::super) fn is_normalized(self) -> bool { // Use the last bit to store if this edge is normalized @@ -249,7 +249,7 @@ impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F> { /// The oriented next edge shares the same face as this edge. /// When traversing the face's edges in oriented order, /// this edge is the predecessor of the oriented next edge. - /// "Oriented" means counterclockwise for right handed + /// "Oriented" means counterclockwise for right-handed /// coordinate systems. pub fn next(&self) -> DirectedEdgeHandle<'a, V, DE, UE, F> { let entry = self.dcel.half_edge(self.handle); @@ -261,7 +261,7 @@ impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F> { /// The oriented previous edge shares the same face as this edge. /// When traversing the face's edges in oriented order, /// this edge is the successor of the oriented previous edge. - /// "Oriented" means counterclockwise for right handed + /// "Oriented" means counterclockwise for right-handed /// coordinate systems. pub fn prev(&self) -> DirectedEdgeHandle<'a, V, DE, UE, F> { let entry = self.dcel.half_edge(self.handle); @@ -276,15 +276,15 @@ impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F> { /// Returns the next edge in clockwise direction. /// - /// Note that this assumes that you use a right handed coordinate system, + /// Note that this assumes that you use a right-handed coordinate system, /// otherwise the sense of orientation is inverted. pub fn cw(&self) -> DirectedEdgeHandle<'a, V, DE, UE, F> { self.rev().next() } - /// Returns the next edge in counter clockwise direction. + /// Returns the next edge in counterclockwise direction. /// - /// Note that this assumes that you use a right handed coordinate system, + /// Note that this assumes that you use a right-handed coordinate system, /// otherwise the sense of orientation is inverted. pub fn ccw(&self) -> DirectedEdgeHandle<'a, V, DE, UE, F> { self.prev().rev() @@ -322,7 +322,7 @@ impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F> { /// Converts this edge into its dual voronoi edge. /// - /// See also [as_delaunay_edge](crate::handles::DirectedVoronoiEdge::as_delaunay_edge). + /// See also [as_delaunay_edge](DirectedVoronoiEdge::as_delaunay_edge). pub fn as_voronoi_edge(&self) -> DirectedVoronoiEdge<'a, V, DE, UE, F> { DirectedVoronoiEdge::new(self.dcel, FixedHandleImpl::new(self.handle.index())) } @@ -591,7 +591,7 @@ impl<'a, V, DE, UE, F> FaceHandle<'a, InnerTag, V, DE, UE, F> { /// #[doc = include_str!("../../../images/face_adjacent_edges.svg")] /// - /// The edges are returned in counter clockwise order. + /// The edges are returned in counterclockwise order. pub fn adjacent_edges(&self) -> [DirectedEdgeHandle<'a, V, DE, UE, F>; 3] { let e1 = self.adjacent_edge(); let e0 = e1.prev(); @@ -610,7 +610,7 @@ impl<'a, V, DE, UE, F> FaceHandle<'a, InnerTag, V, DE, UE, F> { /// Returns the face's three vertices. /// - /// The vertices are returned in counter clockwise order. + /// The vertices are returned in counterclockwise order. pub fn vertices(&self) -> [VertexHandle<'a, V, DE, UE, F>; 3] { let [e0, e1, e2] = self.adjacent_edges(); [e0.from(), e1.from(), e2.from()] @@ -623,7 +623,7 @@ where { /// Returns the positions of the face's vertices /// - /// The positions are returned in counter clockwise order. + /// The positions are returned in counterclockwise order. pub fn positions(&self) -> [Point2; 3] { let [v0, v1, v2] = self.vertices(); [v0.position(), v1.position(), v2.position()] @@ -735,7 +735,7 @@ impl NextBackFn for CCWEdgesNextBackFn { impl<'a, V, DE, UE, F> VertexHandle<'a, V, DE, UE, F> { /// Returns all directed edges going out of this vertex. /// - /// The edges are returned in counter clockwise order, beginning at an arbitrary + /// The edges are returned in counterclockwise order, beginning at an arbitrary /// edge. /// #[doc = include_str!("../../../images/circular_iterator.svg")] diff --git a/src/delaunay_core/handles/iterators/fixed_iterators.rs b/src/delaunay_core/handles/iterators/fixed_iterators.rs index 006075b..61f26a7 100644 --- a/src/delaunay_core/handles/iterators/fixed_iterators.rs +++ b/src/delaunay_core/handles/iterators/fixed_iterators.rs @@ -59,7 +59,7 @@ impl DoubleEndedIterator pub struct DynamicHandleIterator<'a, V, DE, UE, F, Type, InnerOuter> { fixed_iterator: FixedHandleIterator, dcel: &'a Dcel, - inner_outer: core::marker::PhantomData, + inner_outer: PhantomData, } impl<'a, V, DE, UE, F, Type, InnerOuter> DynamicHandleIterator<'a, V, DE, UE, F, Type, InnerOuter> @@ -71,7 +71,7 @@ where DynamicHandleIterator { fixed_iterator: FixedHandleIterator::new(Type::num_elements(dcel)), dcel, - inner_outer: core::marker::PhantomData, + inner_outer: PhantomData, } } } diff --git a/src/delaunay_core/handles/public_handles.rs b/src/delaunay_core/handles/public_handles.rs index fb06571..20102f9 100644 --- a/src/delaunay_core/handles/public_handles.rs +++ b/src/delaunay_core/handles/public_handles.rs @@ -133,7 +133,7 @@ pub type VertexHandle<'a, V, DE = (), UE = (), F = ()> = /// /// Depending on the type parameter, the handle **can refer to the outer face**: /// -/// * `FaceHandle<'a, PossiblyOuterTag, ...>]`: The face may refer to the single outer face. +/// * `FaceHandle<'a, PossiblyOuterTag, ...>`: The face may refer to the single outer face. /// * `FaceHandle<'a, InnerTag, ...>`: The face refers to an inner triangle of the triangulation. /// #[doc = include_str!("../../../images/outer_faces.svg")] @@ -191,7 +191,7 @@ pub enum VoronoiVertex<'a, V, DE, UE, F> { /// Refers to an outer vertex of the voronoi diagram. /// - /// These vertices don't have a well defined position as they don't have a dual inner + /// These vertices don't have a well-defined position as they don't have a dual inner /// face in the Delaunay triangulation. /// Instead, they are characterized by a dual outer edge (an edge that is part of the /// convex hull) of the underlying triangulation. @@ -242,7 +242,7 @@ where /// Returns all directed voronoi edges going out of this vertex. /// - /// The edges are returned in counter clockwise order. Returns `None` if this is an outer + /// The edges are returned in counterclockwise order. Returns `None` if this is an outer /// voronoi vertex. pub fn out_edges(&self) -> Option<[DirectedVoronoiEdge<'a, V, DE, UE, F>; 3]> { match self { @@ -314,7 +314,7 @@ impl<'a, V, DE, UE, F> DirectedVoronoiEdge<'a, V, DE, UE, F> { /// Returns the directed dual edge of the underlying Delaunay triangulation. /// - /// The dual edge is always orthogonal to to this edge. + /// The dual edge is always orthogonal to this edge. /// #[doc = include_str!("../../../images/dual_edges.svg")] /// @@ -328,7 +328,7 @@ impl<'a, V, DE, UE, F> DirectedVoronoiEdge<'a, V, DE, UE, F> { self.as_delaunay_edge().rev().as_voronoi_edge() } - /// Returns the edge that is connected to this edge in counter clockwise order. + /// Returns the edge that is connected to this edge in counterclockwise order. /// /// See also [prev](Self::prev) pub fn next(&self) -> DirectedVoronoiEdge<'a, V, DE, UE, F> { diff --git a/src/delaunay_core/hint_generator.rs b/src/delaunay_core/hint_generator.rs index 07b4626..870b40d 100644 --- a/src/delaunay_core/hint_generator.rs +++ b/src/delaunay_core/hint_generator.rs @@ -127,9 +127,9 @@ impl HintGenerator for LastUsedVertexHintGenerator { /// A hint generator based on a hierarchy of triangulations optimized for randomly accessing elements of /// the triangulation. /// -/// Using this hint generator results in a insertion and lookup performance of O(log(n)) by keeping a +/// Using this hint generator results in an insertion and lookup performance of O(log(n)) by keeping a /// few layers of sparsely populated Delaunay Triangulations. These layers can then be quickly traversed -/// before diving deeper into the next, more detailed layer where the search is then refined. +/// before diving deeper into the next, more detailed layer where the search is furthermore refined. /// /// # Type parameters /// - `S`: The scalar type used by the triangulation diff --git a/src/delaunay_core/interpolation.rs b/src/delaunay_core/interpolation.rs index d10f414..8f64001 100644 --- a/src/delaunay_core/interpolation.rs +++ b/src/delaunay_core/interpolation.rs @@ -165,7 +165,7 @@ where /// unneeded allocations. `result` will be cleared initially. /// /// The number of returned elements depends on the query positions location: - /// - `result` will be **empty** if the query position lies outside of the triangulation's convex hull + /// - `result` will be **empty** if the query position lies outside the triangulation's convex hull /// - `result` will contain **a single element** (with weight 1.0) if the query position lies exactly on a vertex /// - `result` will contain **two vertices** if the query point lies exactly on any edge of the triangulation. /// - `result` will contain **exactly three** elements if the query point lies on an inner face of the @@ -252,7 +252,7 @@ where /// `result` will be cleared initially. /// /// The number of returned natural neighbors depends on the given query position: - /// - `result` will be **empty** if the query position lies outside of the triangulation's convex hull + /// - `result` will be **empty** if the query position lies outside the triangulation's convex hull /// - `result` will contain **exactly one** vertex if the query position is equal to that vertex position. /// - `result` will contain **exactly two** entries if the query position lies exactly *on* an edge of the /// convex hull. @@ -308,7 +308,7 @@ where /// Interpolates a value at a given position. /// - /// In contrast to [Self::interpolate], this method has a well defined derivative at each vertex and will + /// In contrast to [Self::interpolate], this method has a well-defined derivative at each vertex and will /// approximate a linear function in the proximity of any vertex. /// /// The value to interpolate is given by the `i` parameter. The gradient that defines the derivative at @@ -318,7 +318,7 @@ where /// or adheres to it strongly (values larger than ~2.0) in the vicinity of any vertex. When in doubt, using /// a value of 1.0 should result in a good interpolation and is also the fastest. /// - /// Returns `None` for any point outside of the triangulation's convex hull. + /// Returns `None` for any point outside the triangulation's convex hull. /// /// Refer to [NaturalNeighbor] for more information and a visual example. /// @@ -857,7 +857,7 @@ mod test { .is_none()); }; - // Check positions outside of the triangulation. + // Check positions outside the triangulation. for x in [-5.0f64, -4.0, 3.0, 2.0] { expect_none(Point2::new(x, 0.5)); expect_none(Point2::new(x, -0.5)); diff --git a/src/delaunay_core/line_side_info.rs b/src/delaunay_core/line_side_info.rs index 9a0f373..e85fe74 100644 --- a/src/delaunay_core/line_side_info.rs +++ b/src/delaunay_core/line_side_info.rs @@ -1,4 +1,4 @@ -/// Describes on which side of a line a a point lies. +/// Describes on which side of a line a point lies. /// /// Created by [DirectedEdgeHandle::side_query](crate::handles::DirectedEdgeHandle::side_query) #[derive(Debug, Clone, Copy)] @@ -24,7 +24,7 @@ impl LineSideInfo { /// Returns `true` if a point lies on the left side of a line. /// - /// For left handed coordinate systems, this method returns if a point lies on the right side of a line. + /// For left-handed coordinate systems, this method returns if a point lies on the right side of a line. /// This method returns `false` if the point lies exactly on the line. pub fn is_on_left_side(&self) -> bool { self.signed_side > 0.0 @@ -32,7 +32,7 @@ impl LineSideInfo { /// Returns `true` if a point lies on the right side of a line. /// - /// For left handed coordinate systems, this method returns if a point lies on the left side of a line. + /// For left-handed coordinate systems, this method returns if a point lies on the left side of a line. /// This method returns `false` if the point lies exactly on the line. pub fn is_on_right_side(&self) -> bool { self.signed_side < 0.0 @@ -40,7 +40,7 @@ impl LineSideInfo { /// Returns `true` if a point lies on the left side of a line or is on the line itself. /// - /// For left handed coordinate systems, this method returns if a point lies on the left side of a line. + /// For left-handed coordinate systems, this method returns if a point lies on the left side of a line. pub fn is_on_left_side_or_on_line(&self) -> bool { self.signed_side >= 0.0 } diff --git a/src/delaunay_core/math.rs b/src/delaunay_core/math.rs index 4005a55..58e47f8 100644 --- a/src/delaunay_core/math.rs +++ b/src/delaunay_core/math.rs @@ -15,19 +15,19 @@ pub struct PointProjection { /// The error type used for inserting elements into a triangulation. /// /// Errors during insertion can only originate from an invalid vertex position. Vertices can -/// be checked for validity by using [crate::validate_vertex]. +/// be checked for validity by using [validate_vertex]. #[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Hash)] pub enum InsertionError { /// A coordinate value was too small. /// /// The absolute value of any inserted vertex coordinate must either be zero or greater - /// greater than or equal to [crate::MIN_ALLOWED_VALUE]. + /// than or equal to [MIN_ALLOWED_VALUE]. TooSmall, /// A coordinate value was too large. /// /// The absolute value of any inserted vertex coordinate must be less than or equal to - /// [crate::MAX_ALLOWED_VALUE]. + /// [MAX_ALLOWED_VALUE]. TooLarge, /// A coordinate value was NaN. @@ -64,9 +64,9 @@ impl std::error::Error for InsertionError {} // arithmetic is used." // Source: Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates // -// This suggests that the limit as is is needlessly tight as spade only requires two of +// This suggests that the limit as is needlessly tight as spade only requires two of // the four implemented predicates. There is unfortunately no motivation given for these -// limits, hence its not obvious how those would need to be derived. +// limits, hence it is not obvious how those would need to be derived. pub const MIN_ALLOWED_VALUE: f64 = 1.793662034335766e-43; // 1.0 * 2^-142 /// The largest allowed coordinate value that can be inserted into Delaunay triangulations. @@ -282,7 +282,7 @@ where let v3 = to_robust_coord(v3); let p = to_robust_coord(p); - // incircle expects all vertices to be ordered CW for right handed systems. + // incircle expects all vertices to be ordered CW for right-handed systems. // For consistency, the public interface of this method will expect the points to be // ordered ccw. robust::incircle(v3, v2, v1, p) < 0.0 @@ -612,9 +612,9 @@ mod test { let v3 = Point2::new(a3.sin(), a3.cos()).mul(2.).add(offset); assert!(super::side_query(v1, v2, v3).is_on_left_side()); assert!(contained_in_circumference(v1, v2, v3, offset)); - let shrunk = (v1.sub(offset)).mul(0.9).add(offset); + let shrunk = v1.sub(offset).mul(0.9).add(offset); assert!(contained_in_circumference(v1, v2, v3, shrunk)); - let expanded = (v1.sub(offset)).mul(1.1).add(offset); + let expanded = v1.sub(offset).mul(1.1).add(offset); assert!(!contained_in_circumference(v1, v2, v3, expanded)); assert!(!contained_in_circumference( v1, diff --git a/src/delaunay_core/refinement.rs b/src/delaunay_core/refinement.rs index 4443c37..ece729e 100644 --- a/src/delaunay_core/refinement.rs +++ b/src/delaunay_core/refinement.rs @@ -57,7 +57,7 @@ impl AngleLimit { /// /// Defaults to 30°. An angle of 0 degrees will disable refining due to small angles. /// - /// *See also [from_rad](crate::AngleLimit::from_rad)* + /// *See also [from_rad](AngleLimit::from_rad)* pub fn from_deg(degree: f64) -> Self { Self::from_rad(degree.to_radians()) } @@ -67,7 +67,7 @@ impl AngleLimit { /// Note angles larger than 30 degrees (≈0.52rad = PI / 6) will quickly lead to poor refinement quality. /// Passing in an angle of 0rad will disable refining due to small angles. /// - /// *See also [from_deg](crate::AngleLimit::from_deg)* + /// *See also [from_deg](AngleLimit::from_deg)* pub fn from_rad(rad: f64) -> Self { let sin = rad.sin(); if sin == 0.0 { @@ -79,7 +79,7 @@ impl AngleLimit { /// Returns the radius to shortest edge limit corresponding to this angle limit. /// - /// See [from_radius_to_shortest_edge_ratio](crate::AngleLimit::from_radius_to_shortest_edge_ratio) for more + /// See [from_radius_to_shortest_edge_ratio](AngleLimit::from_radius_to_shortest_edge_ratio) for more /// information. pub fn radius_to_shortest_edge_limit(&self) -> f64 { self.radius_to_shortest_edge_limit @@ -406,19 +406,19 @@ where /// /// Refinement will ensure that the resulting triangulation fulfills a few properties: /// - The triangulation's minimum angle will be larger than the angle specified by - /// [with_angle_limit](crate::RefinementParameters::with_angle_limit).
+ /// [with_angle_limit](RefinementParameters::with_angle_limit).
/// *Exception*: Acute input angles (small angles between initial constraint edges) cannot be maximized as the constraint edges /// must be kept intact. The algorithm will, for the most part, leave those places unchanged.
/// *Exception*: The refinement will often not be able to increase the minimal angle much above 30 degrees as every newly /// inserted steiner point may create additional skewed triangles. /// - The refinement will fullfil the *Delaunay Property*: Every triangle's circumcenter will not contain any other vertex.
- /// *Exception*: Refining with [keep_constraint_edges](crate::RefinementParameters::keep_constraint_edges) cannot restore + /// *Exception*: Refining with [keep_constraint_edges](RefinementParameters::keep_constraint_edges) cannot restore /// the Delaunay property if doing so would require splitting a constraint edge.
- /// *Exception*: Refining with [exclude_outer_faces](crate::RefinementParameters::exclude_outer_faces) will not + /// *Exception*: Refining with [exclude_outer_faces](RefinementParameters::exclude_outer_faces) will not /// restore the Delaunay property of any outer face. - /// - Spade allows to specify a [maximum allowed triangle area](crate::RefinementParameters::with_max_allowed_area). + /// - Spade allows to specify a [maximum allowed triangle area](RefinementParameters::with_max_allowed_area). /// The algorithm will attempt to subdivide any triangle with an area larger than this, independent of its smallest angle. - /// - Spade allows to specify a [minimum required triangle area](crate::RefinementParameters::with_min_required_area). + /// - Spade allows to specify a [minimum required triangle area](RefinementParameters::with_min_required_area). /// The refinement will attempt to ignore any triangle with an area smaller than this parameter. This can prevent the /// refinement algorithm from over-refining in some cases. /// @@ -520,12 +520,12 @@ where // the third step in the main loop (see below). We don't simply delete these faces to keep the triangulation's // convexity. // - // Every iterations performs up to three checks: + // Every iteration performs up to three checks: // - First, check if any edges that must be split exists (`forcibly_split_segments_buffer`). // - Second, check if any segment is encroached. If found, resolve the offending encroachment. // Checking segments first makes sure that the algorithm // restores the Delaunay property as quickly as possible. - // - Third, search for skinny triangles. Attempt to insert a new vertex at the triangles circumcenter. If inserting + // - Third, search for skinny triangles. Attempt to insert a new vertex at the triangle's circumcenter. If inserting // such a vertex would encroach any fixed edge, add the encroached edge to the forcibly split segments buffer // and revisit the face later. // @@ -537,7 +537,7 @@ where break; } - // Step 1: Check for forcibly splitted segments. + // Step 1: Check for forcibly split segments. if let Some(forcibly_split_segment) = forcibly_split_segments_buffer.pop() { self.resolve_encroachment( &mut encroached_segment_candidates, @@ -881,7 +881,7 @@ where } } -/// Check if final_position would violate a ordering constraint. This is needed since final_position is constructed +/// Check if final_position would violate an ordering constraint. This is needed since final_position is constructed /// with imprecise calculations and may not even be representable in the underlying floating point type. In rare cases, /// this means that the newly formed triangles would not be ordered ccw. /// We'll simply skip these refinements steps as it should only happen for very bad input geometries. diff --git a/src/delaunay_core/triangulation_ext.rs b/src/delaunay_core/triangulation_ext.rs index 8ccd1e9..eaedcc4 100644 --- a/src/delaunay_core/triangulation_ext.rs +++ b/src/delaunay_core/triangulation_ext.rs @@ -296,7 +296,7 @@ pub trait TriangulationExt: Triangulation { } /// The Delaunay property refers to the property that no point lies inside - /// the circumcircle of any of the triangulation's triangles. Adding a + /// the circumcircle of the triangulation's triangles. Adding a /// new point into the triangulations may violate this property, this method /// "repairs" it by strategically flipping edges until the property /// holds again. Every flip produces more "illegal" edges that may have to @@ -671,7 +671,7 @@ pub trait TriangulationExt: Triangulation { /// - Add all edges of the flip polygon to the invalid list if they were /// newly created. Otherwise, the edge is part of the border loop surrounding /// the hole created after the vertex removal. These are known to be valid and - /// need not to be checked + /// need not be checked /// /// For more details, refer to /// Olivier Devillers. Vertex Removal in Two Dimensional Delaunay Triangulation: @@ -950,7 +950,7 @@ mod test { fn test_insert_outside_convex_hull() -> Result<(), InsertionError> { const NUM: usize = 100; let mut rng = rand::rngs::StdRng::from_seed(*SEED); - let range = Uniform::new(0., 2.0 * ::core::f64::consts::PI); + let range = Uniform::new(0., 2.0 * core::f64::consts::PI); let mut d = DelaunayTriangulation::<_>::default(); diff --git a/src/delaunay_triangulation.rs b/src/delaunay_triangulation.rs index 6ece0f2..7b4f634 100644 --- a/src/delaunay_triangulation.rs +++ b/src/delaunay_triangulation.rs @@ -10,7 +10,7 @@ use num_traits::Float; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -/// A two dimensional [Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation). +/// A two-dimensional [Delaunay triangulation](https://en.wikipedia.org/wiki/Delaunay_triangulation). /// /// A Delaunay triangulation a triangulation that fulfills the *Delaunay Property*: No /// vertex of the triangulation is contained in the @@ -28,7 +28,7 @@ use serde::{Deserialize, Serialize}; /// /// # Basic Usage /// Vertices need to implement the [HasPosition] trait. Spade bundles -/// the [Point2](crate::Point2) struct for basic use cases. +/// the [Point2] struct for basic use cases. /// /// ## Basic example /// ``` @@ -49,15 +49,15 @@ use serde::{Deserialize, Serialize}; /// Ok(()) /// } /// ``` -/// ## Right handed and left handed coordinate systems +/// ## Right handed and left-handed coordinate systems /// For simplicity, all method names and their documentation assume that the underlying coordinate system -/// is right handed (e.g. x axis points to the right, y axis points upwards). If a left handed system +/// is right-handed (e.g. x-axis points to the right, y-axis points upwards). If a left-handed system /// (lhs) is used, any term related to orientation needs to be reversed: -/// - "left" becomes "right" (example: the face of a directed edge is on the right side for a lhs +/// - "left" becomes "right" (example: the face of a directed edge is on the right side for a lhs) /// - "counter clock wise" becomes "clockwise" (example: the vertices of a face are returned in clock wise order for a lhs) /// /// -/// +/// ///
left handed systemright handed system
left-handed systemright-handed system
#[doc = concat!(include_str!("../images/lhs.svg"), "",include_str!("../images/rhs.svg"), "
")] /// # Extracting geometry information @@ -237,7 +237,7 @@ use serde::{Deserialize, Serialize}; /// - For data sets with uniformly distributed vertices: Use [HierarchyHintGenerator](crate::HierarchyHintGenerator) if /// bulk loading is not applicable. /// - For data sets where vertices are inserted in close local proximity (each vertex is not too far away from the -/// previously inserted vertex): Consider using [LastUsedVertexHintGenerator](crate::LastUsedVertexHintGenerator). +/// previously inserted vertex): Consider using [LastUsedVertexHintGenerator](LastUsedVertexHintGenerator). /// - Try to avoid large custom data types for edges, vertices and faces. /// - Using `f64` and `f32` as scalar type will usually end up roughly having the same run time performance. /// - Prefer using [bulk_load](Triangulation::bulk_load) over [insert](Triangulation::insert). @@ -457,7 +457,7 @@ mod test { fn requires_serde<'de, T: Serialize + Deserialize<'de>>() {} - type DT = super::DelaunayTriangulation, (), (), (), L>; + type DT = DelaunayTriangulation, (), (), (), L>; requires_serde::>(); requires_serde::>>(); diff --git a/src/flood_fill_iterator.rs b/src/flood_fill_iterator.rs index 12a2965..d26ffae 100644 --- a/src/flood_fill_iterator.rs +++ b/src/flood_fill_iterator.rs @@ -58,7 +58,7 @@ where { fn is_edge_inside(&self, points: [Point2; 2]) -> bool { let [p0, p1] = points; - crate::delaunay_core::math::distance_2(p0, p1, self.center) <= self.radius_2 + math::distance_2(p0, p1, self.center) <= self.radius_2 } fn distance_to_point(&self, point: Point2) -> S { @@ -93,20 +93,6 @@ where S: SpadeNum, S: Float, { - fn distance_to_point(&self, point: Point2) -> S { - if self.lower == self.upper { - return point.distance_2(self.lower); - } - - if self.is_point_inside(point) { - zero() - } else { - let [d0, d1, d2, d3] = self.edges().map(|[p0, p1]| math::distance_2(p0, p1, point)); - - d0.min(d1).min(d2).min(d3) - } - } - fn is_edge_inside(&self, points: [Point2; 2]) -> bool { let [from, to] = points; if self.is_point_inside(from) || self.is_point_inside(to) { @@ -138,6 +124,20 @@ where } false } + + fn distance_to_point(&self, point: Point2) -> S { + if self.lower == self.upper { + return point.distance_2(self.lower); + } + + if self.is_point_inside(point) { + zero() + } else { + let [d0, d1, d2, d3] = self.edges().map(|[p0, p1]| math::distance_2(p0, p1, point)); + + d0.min(d1).min(d2).min(d3) + } + } } impl RectangleMetric diff --git a/src/intersection_iterator.rs b/src/intersection_iterator.rs index 2ae269d..5df43e6 100644 --- a/src/intersection_iterator.rs +++ b/src/intersection_iterator.rs @@ -1,6 +1,6 @@ +use crate::{HasPosition, Point2, Triangulation, TriangulationExt}; use crate::delaunay_core::math; use crate::handles::{DirectedEdgeHandle, FixedVertexHandle, VertexHandle}; -use crate::{HasPosition, Point2, Triangulation, TriangulationExt}; /// An iterator over all intersections of a straight line across the triangulation. /// @@ -37,10 +37,10 @@ use crate::{HasPosition, Point2, Triangulation, TriangulationExt}; /// ]; /// /// let triangulation = DelaunayTriangulation::<_>::bulk_load_stable(vertices)?; -/// for intersection in spade::LineIntersectionIterator::new( +/// for intersection in LineIntersectionIterator::new( /// &triangulation, -/// spade::Point2::new(-30.0, 0.0), -/// spade::Point2::new(40.0, 0.0), +/// Point2::new(-30.0, 0.0), +/// Point2::new(40.0, 0.0), /// ) { /// println!("{:?}", intersection); /// } @@ -77,7 +77,7 @@ where V: HasPosition, { /// Indicates that the line is either crossing or touching an existing edge. - /// The line's destination will always be either on the edge or on its left side (in a left handed coordinate system). + /// The line's destination will always be either on the edge or on its left side (in a right-handed coordinate system). EdgeIntersection(DirectedEdgeHandle<'a, V, DE, UE, F>), /// Indicates that the line is touching a vertex. /// A line beginning or starting on a vertex also generates this intersection. A "line" beginning and starting on the same @@ -89,11 +89,11 @@ where EdgeOverlap(DirectedEdgeHandle<'a, V, DE, UE, F>), } -impl<'a, V, DE, UE, F> ::core::fmt::Debug for Intersection<'a, V, DE, UE, F> +impl<'a, V, DE, UE, F> core::fmt::Debug for Intersection<'a, V, DE, UE, F> where V: HasPosition, { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { use self::Intersection::*; match self { EdgeIntersection(handle) => write!(f, "EdgeIntersection({:?})", handle), @@ -336,15 +336,13 @@ where } else { match trace_direction_out_of_vertex(vertex, self.line_to) { VertexOutDirection::ConvexHull => None, - VertexOutDirection::EdgeOverlap(edge) => { - Some(Intersection::EdgeOverlap(edge)) - } + VertexOutDirection::EdgeOverlap(edge) => Some(EdgeOverlap(edge)), VertexOutDirection::EdgeIntersection(edge) => { if edge.side_query(self.line_to).is_on_right_side() { // The target point was skipped over - the iteration can finish None } else { - Some(Intersection::EdgeIntersection(edge)) + Some(EdgeIntersection(edge)) } } } diff --git a/src/lib.rs b/src/lib.rs index 8fe66fa..f2978c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ //! # Spade //! -//! Delaunay triangulations for the rust eco system. +//! Delaunay triangulations for the rust ecosystem. //! //! # Features //! * A 2D Delaunay triangulation: [DelaunayTriangulation] @@ -69,6 +69,7 @@ mod test_utilities; /// more limited API. /// /// # Reference handles +/// /// Reference handles come in one of four variants: /// * [FaceHandle](handles::FaceHandle)s refer to a single face (triangle) of the triangulation. /// They are used get the triangle's adjacent vertices and edges. They also may refer to @@ -117,7 +118,7 @@ mod test_utilities; /// /// # Creating handles directly /// -/// In some cases it may be desireable to create vertex handles artificially by providing the index +/// In some cases it may be desirable to create vertex handles artificially by providing the index /// manually. This can be done by calling [handles::FixedVertexHandle::from_index](from_index(usize)). /// Make sure that the provided index is smaller than the number of vertices in the triangulation. /// diff --git a/src/point.rs b/src/point.rs index f4283f2..a435eb4 100644 --- a/src/point.rs +++ b/src/point.rs @@ -19,7 +19,7 @@ impl SpadeNum for T where { } -/// A two dimensional point. +/// A two-dimensional point. /// /// This is the basic type used for defining positions. #[derive(Debug, PartialEq, Eq, PartialOrd, Clone, Copy, Default, Hash)] diff --git a/src/triangulation.rs b/src/triangulation.rs index 838817a..daba6a8 100644 --- a/src/triangulation.rs +++ b/src/triangulation.rs @@ -44,7 +44,7 @@ pub enum PositionInTriangulation { /// Defines common operations on triangulations. /// /// These operations are both available for -/// [ConstrainedDelaunayTriangulations](crate::ConstrainedDelaunayTriangulation) as well as +/// [ConstrainedDelaunayTriangulations](crate::ConstrainedDelaunayTriangulation) and /// regular [DelaunayTriangulations](crate::DelaunayTriangulation). pub trait Triangulation: Default { /// The triangulation's vertex type. @@ -160,7 +160,7 @@ pub trait Triangulation: Default { /// # Runtime /// /// This method has a run time of `O(n)` but will run near linearly in practice. - /// The runtime can be as worse as `O(n²)` if the inputs are very degenerate, e.g. + /// The runtime can be as bad as `O(n²)` if the inputs are very degenerate, e.g. /// if all input vertices lie on the same line. /// /// # Comparison to incremental insertion @@ -213,7 +213,7 @@ pub trait Triangulation: Default { self.s().outer_face() } - /// Converts a fixed directed edge handle handle to a reference directed edge handle. + /// Converts a fixed directed edge handle to a reference directed edge handle. /// /// *See also the [handles](crate::handles) module for more information.* fn directed_edge( @@ -355,7 +355,7 @@ pub trait Triangulation: Default { /// An iterator visiting all directed voronoi edges. /// - /// The iterator type is (DirectedVoronoiEdge)[crate::handles::DirectedVoronoiEdge] + /// The iterator type is (DirectedVoronoiEdge)[DirectedVoronoiEdge] fn directed_voronoi_edges( &self, ) -> DirectedVoronoiEdgeIterator< @@ -369,7 +369,7 @@ pub trait Triangulation: Default { /// An iterator visiting all undirected voronoi edges. /// - /// The iterator type is (UndirectedVoronoiEdge)[crate::handles::UndirectedVoronoiEdge] + /// The iterator type is (UndirectedVoronoiEdge)[UndirectedVoronoiEdge] fn undirected_voronoi_edges( &self, ) -> UndirectedVoronoiEdgeIterator<