Skip to content

Commit c7b571b

Browse files
committed
Update docs
1 parent b223634 commit c7b571b

File tree

7 files changed

+65
-1
lines changed

7 files changed

+65
-1
lines changed

docs/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DelaunayTriangulation = "927a84f5-c5f4-47a5-9785-b46e178433df"
66
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
77
DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8"
88
ElasticArrays = "fdbdab4c-e67f-52f5-8c3f-e7b388dad3d4"
9+
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
910
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1011
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1112
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"

docs/make.jl

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ const _PAGES = [
180180
"Mesh Refinement" => "math/refinement.md",
181181
"Curves" => "math/curves.md",
182182
"Triangulating Curve-Bounded Domains" => "math/curve_bounded.md",
183+
"Weighted Delaunay Triangulations" => "math/weighted.md",
183184
"Voronoi Tessellations" => "math/voronoi.md",
184185
"Clipped Voronoi Tessellations" => "math/clipped.md",
185186
"Centroidal Voronoi Tessellations" => "math/centroidal.md",

docs/src/math/weighted.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Weighted Triangulations
2+
3+
Here we give a brief overview of the details behind weighted Delaunay triangulations. For a more
4+
detailed description, see Chapters 2 and 3 of the book [_Delaunay Mesh Generation_ by Cheng, Dey, and Shewchuk (2013)](https://people.eecs.berkeley.edu/~jrs/meshbook.html).
5+
6+
## Parabolic Lifting Map
7+
8+
The definition of a weighted triangulation is derived from the idea of a _parabolic lifting map_. The parabolic lifting map takes a triangulation $\mathcal D\mathcal T(\mathcal P)$ of a finite point set $\mathcal p$ and projects it to a parabolid in $\mathbb R^3$ via the map $\mathcal L \colon \mathbb R^2 \to \mathbb R^3$ defined by $\mathcal L(p) = (p_x, p_y, p_x^2 + p_y^2)$. The point $\mathcal L(p)$ is the _lifted compansion_ of $p$, denoted $p^+$. An example of this mapping applied to a triangulation is shown below.
9+
10+
```@setup weighted_ex1
11+
using DelaunayTriangulation
12+
using CairoMakie
13+
using StableRNGs
14+
import GeometryBasics
15+
rng = StableRNG(127)
16+
points = tuple.(4randn(rng, 20), 4randn(rng, 20))
17+
tri = triangulate(points; rng)
18+
projected_points = tuple.(first.(points), last.(points), 0.0)
19+
lifted_points = DelaunayTriangulation.get_lifted_point.((tri,), DelaunayTriangulation.each_point_index(tri))
20+
triangles = GeometryBasics.TriangleFace.(each_solid_triangle(tri))
21+
fig = Figure()
22+
ax = Axis3(fig[1, 1], azimuth = 0.4, elevation = pi / 12 - 0.1, perspectiveness = 0.1)
23+
pmesh = GeometryBasics.Mesh(Point3.(projected_points), triangles)
24+
lmesh = GeometryBasics.Mesh(Point3.(lifted_points), triangles)
25+
poly!(ax, pmesh, color = (:white, 0.0), strokecolor = :black, strokewidth = 1)
26+
poly!(ax, lmesh, color = (:white, 0.0), strokecolor = :red, strokewidth = 1)
27+
resize_to_layout!(fig)
28+
```
29+
30+
```@example weighted_ex1
31+
fig # hide
32+
```
33+
34+
Let $\mathcal P^+$ denote the set of lifted points. It can be shown that the projection of the underside of the convex hull of $\mathcal P^+$, meaning the projection of all faces of the convex hull with a downward-facing normal (where the positive $z$-axis points upward), is equal to $\mathcal D\mathcal T(\mathcal P)$; see Proposition 2.2 in the reference above. This is the basis for the definition of a weighted Delaunay triangulation.
35+
36+
## Weighted Delaunay Triangulations
37+
38+
Weighted Delaunay triangulations allow the lifted points $p^+$ to live away from the paraboloid $x^2 + y^2$. In particular, augment each point $p_i \in \mathcal P$ with a weight $w_i$ such that the lifted point is $p_i^+ = (x_i, y_i, x_i^2 + y_i^2 - w_i)$. The point $w_i$ gives the deviation of $p_i^+$ from the paraboloid. In particular, $w_i > 0$ means the point is below the paraboloid, and $w_i < 0$ means it is below; the sign convention here is defined so that increasing $w_i$ increases its affect on the underside of the convex hull of $\mathcal P^+$, the set of lifted points. The _weighted Delaunay triangulation_ is then defined to be the projection of the underside of the convex hull of $\mathcal P^+$.
39+
40+
Given this definition, it is possible that not all points will appear in the weighted triangulation, since not all faces will be projected in this case. Such points are said to be _submerged_ or _redundant_.
41+
42+
## Constructing Weighted Triangulations
43+
44+
The algorithm for constructing weighted triangulations is a simple modification of the standard Bowyer-Watson algorithm. The only difference is the test of whether a point is inside a triangle's circumcircle. Instead of circumcircles, we use _witness planes_.
45+
46+
From the definition of the weighted triangulation, a point will only be included in the triangulation if it is part of a downward-facing face of the convex hull of $\mathcal P^+$. The definition of the convex hull thus means that, instead of checking if a triangle's circumcircle contains a point, we should instead be checking if that point is below the plane through that triangle, i.e. the _witness plane_. A point that is below this witness plane is _submerged_.
47+
48+
Thus, the Bowyer-Watson algorithm can be extended to weighted triangulations by simply replacing calls to `point_position_relative_to_circumcircle` with calls to a predicate that checks if a point is below a witness plane. This has been implemented in the `point_position_relative_to_witness_plane` predicate. Care is needed for ghost triangles - if a point is being inserted onto the solid edge of a ghost triangle, we say it is below the ghost triangle's witness plane if it is not submerged relative to the solid triangle opposite the ghost triangle. The only other modification to the algorithm needed is to be careful that it is not guaranteed that there exists any triangle whose witness plane is above a new point, in which case that point's insertion should be completely rejected.

docs/src/tutorials/overview.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The tutorials that we consider are as follows:
2525
- [Triangulating Rectangular Regions](lattice.md): A simple example of how rectangular regions in the plane can be triangulated quickly.
2626
- [Triangulating Convex Polygons](convex.md): How triangulations of convex polygons can be computed.
2727
- [Triangulation Curve-Bounded Domains](curve_bounded.md): How triangulations of curve-bounded domains can be computed.
28+
- [Weighted Triangulations](weighted.md): How weighted Delaunay triangulations can be computed.
2829
- [Voronoi Tessellations](voronoi.md): How Voronoi tessellations can be computed. We also give examples of how you can iterate over the edges and generators in the tessellation, and other features.
2930
- [Clipped Voronoi Tessellations](clipped.md): How to compute a Voronoi tessellation of a point set such that the polygons are [clipped to the point set's convex hull](clipped.md), or [to an arbitrary rectangle](clipped_rectangle.md).
3031
- [Centroidal Voronoi Tessellation](centroidal.md): How to compute centroidal Voronoi tessellations, in particular how to shift a given set of points so that each point's associated Voronoi tile is that tile's centroid.

src/data_structures/triangulation/methods/weights.jl

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ Struct used for indicating that a triangulation has zero weights. The weights ar
2121
struct ZeroWeight end
2222
get_weight(::ZeroWeight, i) = zero(Float64)
2323

24+
function Base.:(==)(w₁::ZeroWeight, w₂::ZeroWeight)
25+
return true
26+
end
27+
function Base.:(==)(w₁::ZeroWeight, w₂)
28+
return all(iszero, w₂)
29+
end
30+
function Base.:(==)(w₁, w₂::ZeroWeight)
31+
return all(iszero, w₁)
32+
end
33+
2434
"""
2535
add_weight!(tri::Triangulation, w)
2636

test/data_structures/triangulation.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ end
194194
@test all((tri.graph.neighbours[28371]), (50912, 271, 501))
195195
DT.delete_neighbour!(tri, 28371, 50912)
196196
DT.delete_neighbour!(tri, 28371, 271, 501)
197-
@test all((tri.graph.neighbours[28371]), (50912, 271, 501))
197+
@test !haskey(tri.graph.neighbours, 28371)
198198
DT.delete_vertex!(tri, 19998)
199199
DT.delete_vertex!(tri, 28371, 3)
200200
@test all((tri.graph.vertices), (19998, 28371, 3))

test/triangulation/weighted.jl

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ using ..DelaunayTriangulation: add_weight!, get_weight, get_weights
99
zw = DT.ZeroWeight()
1010
@inferred DT.ZeroWeight()
1111
@test get_weight(zw, 1) 0.0
12+
13+
@test zw == zeros(10)
14+
@test zeros(10) == zw
1215
end
1316

1417
@testset "get_weight" begin

0 commit comments

Comments
 (0)