-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement weighted Delaunay triangulations and power diagrams (#180)
- Loading branch information
1 parent
e88077b
commit 4c58e00
Showing
67 changed files
with
2,446 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "DelaunayTriangulation" | ||
uuid = "927a84f5-c5f4-47a5-9785-b46e178433df" | ||
authors = ["Daniel VandenHeuvel <[email protected]>"] | ||
version = "1.2.0" | ||
version = "1.3.0" | ||
|
||
[deps] | ||
AdaptivePredicates = "35492f91-a3bd-45ad-95db-fcad7dcfedb7" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# # Clipped Voronoi Tessellations | ||
# ## Clipping to a Generic Convex Polygon | ||
# | ||
|
||
# In this tutorial we show how to clip a Voronoi tessellation to | ||
# more generic convex polygons (non-convex polygons are not currently supported) than just a convex hull or a rectangle. This is | ||
# done by using the `clip_polygon` keyword argument in `voronoi`. | ||
|
||
# We start by clipping the tessellation to a rectangle, showing an alternative | ||
# to the [previous tutorial](clipped_rectangle.md). To start, we load in the packages | ||
# we need and generate some data. | ||
using DelaunayTriangulation | ||
using DelaunayTriangulation: EllipticalArc | ||
using CairoMakie | ||
using StableRNGs | ||
using ReferenceTests #src | ||
using Test #src | ||
fig_path = joinpath(@__DIR__, "../figures") #src | ||
|
||
rng = StableRNG(123) | ||
points = randn(rng, 2, 50) | ||
tri = triangulate(points; rng) | ||
vorn = voronoi(tri) | ||
|
||
# To define the polygon, we define the points and vertices just as we would, for example, | ||
# the boundary of a triangulation. | ||
xmin, xmax, ymin, ymax = -1/2, 1/2, -1.0, 1.0 | ||
clip_points = ((xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax)) | ||
clip_vertices = (1, 2, 3, 4, 1) | ||
clip_polygon = (clip_points, clip_vertices) | ||
|
||
# Now we simply pass the polygon into `voronoi`. | ||
clipped_vorn = voronoi(tri, clip = true, clip_polygon = clip_polygon) | ||
|
||
# Now let's look at the results. | ||
fig = Figure() | ||
ax1 = Axis(fig[1, 1], title = "Unclipped", width = 600, height = 400) | ||
ax2 = Axis(fig[1, 2], title = "Clipped", width = 600, height = 400) | ||
voronoiplot!(ax1, vorn, show_generators = false, colormap = :matter, strokewidth = 4) | ||
xlims!(ax1, -2, 2) | ||
ylims!(ax1, -2, 2) | ||
lines!(ax1, [clip_points..., clip_points[begin]], color = :black, linewidth = 4, linestyle = :dash) | ||
voronoiplot!(ax2, clipped_vorn, show_generators = false, colormap = :matter, strokewidth = 4) | ||
xlims!(ax2, -2, 2) | ||
ylims!(ax2, -2, 2) | ||
resize_to_layout!(fig) | ||
fig | ||
@test_reference joinpath(fig_path, "generic_clipped_voronoi_ex_1.png") fig #src | ||
|
||
# We can clip to any convex polygon that we want to. For example, below we clip to an elliptical boundary. | ||
rng = StableRNG(123333) | ||
points = randn(rng, 2, 50) | ||
tri = triangulate(points; rng) | ||
vorn = voronoi(tri) | ||
ellip = EllipticalArc((1/2, 0.0), (1/2, 0.0), (0.0, 0.0), 1/2, 1.0, 0.0) | ||
t = LinRange(0, 1, 50) | ||
clip_points = ellip.(t) | ||
clip_vertices = [1:(length(clip_points)-1); 1] | ||
clip_polygon = (clip_points, clip_vertices) | ||
clipped_vorn = voronoi(tri, clip = true, clip_polygon = clip_polygon) | ||
fig = Figure() | ||
ax1 = Axis(fig[1, 1], title = "Unclipped", width = 600, height = 400) | ||
ax2 = Axis(fig[1, 2], title = "Clipped", width = 600, height = 400) | ||
voronoiplot!(ax1, vorn, show_generators = false, colormap = :matter, strokewidth = 4) | ||
xlims!(ax1, -2, 2) | ||
ylims!(ax1, -2, 2) | ||
lines!(ax1, [clip_points..., clip_points[begin]], color = :black, linewidth = 4, linestyle = :dash) | ||
voronoiplot!(ax2, clipped_vorn, show_generators = false, colormap = :matter, strokewidth = 4) | ||
xlims!(ax2, -2, 2) | ||
ylims!(ax2, -2, 2) | ||
resize_to_layout!(fig) | ||
fig | ||
@test_reference joinpath(fig_path, "generic_clipped_voronoi_ex_2.png") fig #src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
4c58e00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
4c58e00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/114774
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: