d2p: Disk to Polygon

View source: R/d2p.R

d2pR Documentation

Disk to Polygon

Description

Map the data within the unit disk to a polygon via Schwarz-Christoffel conformal mapping.

Usage

d2p(.data, pg = sccm::polygon(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)), ...)

Arguments

.data

the (x, y) corrdnates of the data within the unit disk.

pg

the polygon to map the data to.

...

additional arguments passed to scmap

Value

a sccm_d2p object, a list with the following elements:

mapped

a n by 2 matrix with the (x, y) coordinates of the mapped data.

polygon

The polygon the data was mapped into

data

The original data

mapping

the Schwarz-Christoffel mapping used.

See Also

scmap p2p p2d

Examples


# 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))



dewittpe/sccm documentation built on Feb. 2, 2024, 5:25 p.m.