d2p | R Documentation |
Map the data within the unit disk to a polygon via Schwarz-Christoffel conformal mapping.
d2p(.data, pg = sccm::polygon(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)), ...)
.data |
the (x, y) corrdnates of the data within the unit disk. |
pg |
the polygon to map the data to. |
... |
additional arguments passed to |
a sccm_d2p
object, a list with the following elements:
a n by 2 matrix with the (x, y) coordinates of the mapped data.
The polygon the data was mapped into
The original data
the Schwarz-Christoffel mapping used.
scmap
p2p
p2d
# Examples using MC Escher's Circle Limit I
data("CircleLimitI", package = "sccm")
# map to a square
mce <- sccm::d2p(CircleLimitI[, c("x", "y")])
plot(mce, col = cut(CircleLimitI$value, breaks = 2), pch = ".", cex = 3)
# map to a star
star <-
rbind(sccm::polar2cartesian(r = 1.0, theta = seq(0, 1.6, by = 0.4) * pi),
sccm::polar2cartesian(r = 0.6, theta = seq(0.2, 1.8, by = 0.4) * pi))
star <- star[rep(1:5, each = 2) + rep(c(0, 5), times = 5), ]
mce_star <-
sccm::d2p(
CircleLimitI[, c("x", "y")],
pg = sccm::polygon(star[, 1:2]),
wc = c(0, 0)
)
plot(mce_star, col = cut(CircleLimitI$value, breaks = 2), pch = 16)
# Examples based on a color disk
color_disk <-
Reduce(rbind,
c(
mapply(function(r, theta) {cbind(sccm::polar2cartesian(r, theta), r)},
r = seq(0.1, 0.9, by = 0.1),
MoreArgs = list(theta = seq(0, 2 * pi, length = 100L)),
SIMPLIFY = FALSE),
mapply(function(r, theta) {cbind(sccm::polar2cartesian(r, theta), r)},
theta = seq(0, 2, by = 0.25) * pi,
MoreArgs = list(r = seq(0, 0.99, length = 20L)),
SIMPLIFY = FALSE)
))
color_disk_squared <- sccm::d2p(color_disk[, 1:2])
plot(color_disk_squared, col = cut(color_disk[, 3], breaks = 6))
color_disk_squared <- sccm::d2p(color_disk[, 1:2],
pg = sccm::polygon(star))
plot(color_disk_squared, col = cut(color_disk[, 3], breaks = 6))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.