p2p: Polygon to Polygon

View source: R/p2p.R

p2pR Documentation

Polygon to Polygon

Description

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

Usage

p2p(
  .data,
  pg1 = sccm::convex_hull(.data),
  pg2 = sccm::polygon(x = c(-1, 1, 1, -1), y = c(-1, -1, 1, 1)),
  ...
)

Arguments

.data

the data set to map

pg1

the polygon containing the .data

pg2

the polygon to map .data to.

...

additional arguments passed to scmap

Value

a sccm_p2d object, a list with the following elements:

mapped

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

disked

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

data

The original data

pg1

The polygon the .data was contained in

pg2

The polygon the .data was mapped into

p2d

the Schwarz-Christoffel mapping between the unit disk and polygon1.

d2p

the Schwarz-Christoffel mapping between the unit disk and polygon2.

See Also

scmap d2p p2d

Examples

set.seed(42)
n <- 2500L
dat <- data.frame(x = 1 + runif(n)) 
dat$y <- log(dat$x) + rnorm(n, sd = 0.2)
ch <- sccm::convex_hull(dat)
plot(ch)

trans <- sccm::p2p(dat)
plot(trans)

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), ]

trans <- sccm::p2p(dat, pg2 = sccm::polygon(star))
plot(trans)



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