Title: | 2D Apollonius Graphs |
---|---|
Description: | Computation of the Apollonius diagram of given 2D points and its dual the Apollonius graph, also known as the additively weighted Voronoï diagram, and which is a generalization of the classical Voronoï diagram. For references, see the bibliography in the CGAL documentation at <https://doc.cgal.org/latest/Apollonius_graph_2/citelist.html>. |
Authors: | Stéphane Laurent [aut, cre] |
Maintainer: | Stéphane Laurent <[email protected]> |
License: | GPL-3 |
Version: | 1.0.1 |
Built: | 2024-11-02 04:43:15 UTC |
Source: | https://github.com/stla/apollonius |
Computation of the Apollonius diagram and the Apollonius graph of some weighted 2D points. The Apollonius graph is the dual of the Apollonius diagram. It is also called the additively weighted Voronoï diagram.
Apollonius(sites, radii, tmax = 30, nsegs = 100L, nrays = 300L)
Apollonius(sites, radii, tmax = 30, nsegs = 100L, nrays = 300L)
sites |
the 2D points, a numeric matrix with two columns (one point per row) |
radii |
the weights, a numeric vector of length equal to the number of
points (i.e. the number of rows of |
tmax |
a positive number passed to |
nsegs |
a positive integer, the desired number of points of each finite edge of the Apollonius graph |
nrays |
a positive integer, the desired number of points of each infinite edge of the Apollonius graph |
See the CGAL documentation.
A list with two fields diagram
and graph
. The
diagram
field is a list providing the sites and the faces of the
Apollonius diagram. The graph
field is a list providing the sites
and the edges of the Apollonius graph.
library(Apollonius) sites <- rbind( c(0, 0), c(4, 1), c(2, 4), c(7, 4), c(8, 0), c(5, -2), c(-4, 4), c(-2, -1), c(11, 4), c(11, 0) ) radii <- c(1, 1.5, 1.25, 2, 1.75, 0.5, 0.4, 0.6, 0.7, 0.3) apo <- Apollonius(sites, radii) opar <- par(mar = c(4, 4, 1, 1)) plotApolloniusGraph(apo, xlab = "x", ylab = "y") par(opar) # Example of a non-valid graph #### library(Apollonius) sites <- rbind( c(-1, -1), c(-1, 1), c(1, 1), c(1, -1), c(0, 0) ) angle_ <- seq(0, 2*pi, length.out = 13L)[-1L] circle <- cbind(2 * cos(angle_), 2 * sin(angle_)) sites <- rbind(sites, circle) radii <- c(rep(2, 5), rep(1, 12)) ## Not run: apo <- Apollonius(sites, radii)
library(Apollonius) sites <- rbind( c(0, 0), c(4, 1), c(2, 4), c(7, 4), c(8, 0), c(5, -2), c(-4, 4), c(-2, -1), c(11, 4), c(11, 0) ) radii <- c(1, 1.5, 1.25, 2, 1.75, 0.5, 0.4, 0.6, 0.7, 0.3) apo <- Apollonius(sites, radii) opar <- par(mar = c(4, 4, 1, 1)) plotApolloniusGraph(apo, xlab = "x", ylab = "y") par(opar) # Example of a non-valid graph #### library(Apollonius) sites <- rbind( c(-1, -1), c(-1, 1), c(1, 1), c(1, -1), c(0, 0) ) angle_ <- seq(0, 2*pi, length.out = 13L)[-1L] circle <- cbind(2 * cos(angle_), 2 * sin(angle_)) sites <- rbind(sites, circle) radii <- c(rep(2, 5), rep(1, 12)) ## Not run: apo <- Apollonius(sites, radii)
Plot an Apollonius graph.
plotApolloniusGraph( apo, limits = NULL, circles = TRUE, fill = TRUE, centers = TRUE, colors = "distinct", distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")), randomArgs = list(hue = "random", luminosity = "dark"), ... )
plotApolloniusGraph( apo, limits = NULL, circles = TRUE, fill = TRUE, centers = TRUE, colors = "distinct", distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")), randomArgs = list(hue = "random", luminosity = "dark"), ... )
apo |
an output of |
limits |
either |
circles |
Boolean, whether to plot the original sites as circles with the given radii |
fill |
Boolean, whether to fill the circles if |
centers |
when |
colors |
a character string controlling the colors of the sites;
|
distinctArgs |
if |
randomArgs |
if |
... |
arguments passed to |
No returned value, called for plotting.
library(Apollonius) sites <- rbind( c(0, 0), c(4, 1), c(2, 4), c(7, 4), c(8, 0), c(5, -2), c(-4, 4), c(-2, -1), c(11, 4), c(11, 0) ) radii <- c(1, 1.5, 1.25, 2, 1.75, 0.5, 0.4, 0.6, 0.7, 0.3) apo <- Apollonius(sites, radii) opar <- par(mar = c(3, 3, 1, 1)) plotApolloniusGraph( apo, fill = FALSE, colors = "random", xlab = NA, ylab = NA ) par(opar)
library(Apollonius) sites <- rbind( c(0, 0), c(4, 1), c(2, 4), c(7, 4), c(8, 0), c(5, -2), c(-4, 4), c(-2, -1), c(11, 4), c(11, 0) ) radii <- c(1, 1.5, 1.25, 2, 1.75, 0.5, 0.4, 0.6, 0.7, 0.3) apo <- Apollonius(sites, radii) opar <- par(mar = c(3, 3, 1, 1)) plotApolloniusGraph( apo, fill = FALSE, colors = "random", xlab = NA, ylab = NA ) par(opar)