Skip to content

Commit

Permalink
brol
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Nov 12, 2023
1 parent 113c530 commit 1ca2eab
Show file tree
Hide file tree
Showing 13 changed files with 801 additions and 0 deletions.
106 changes: 106 additions & 0 deletions inst/images/Eisenstein4_Cayley.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
library(jacobi)
library(RcppColors)

# the modified Cayley transformation
Phi <- function(z) (1i*z + 1) / (z + 1i)
PhiInv <- function(z) {
1i + (2i*z) / (1i - z)
}

# background color
bkgcol <- "#ffffff"


# make the color mapping
f <- function(x, y) {
z <- complex(real = x, imaginary = y)
tau <- PhiInv(z)
ifelse(
Mod(z) >= 1,
NA_complex_,
EisensteinE(4L, exp(1i*pi*tau))
)
}
x <- y <- seq(-1, 1, length.out = 512L)
S <- outer(x, y, Vectorize(f))


img <- colorMap7(Im(S))
img <- colorMap5(S)

opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)

############################################################################
n <- 2048L
x <- y <- seq(0.0001, 0.9999, length.out = n)
Grid <- transform(
expand.grid(X = x, Y = y),
Z = complex(real = X, imaginary = Y)
)
Tau <- square2H(Grid$Z)
Q <- exp(1i*pi*Tau)
K <- vapply(Q, function(q) EisensteinE(6L, q), complex(1L))
dim(K) <- c(n, n)
# plot
if(require("RcppColors")) {
img <- colorMap5(K)
} else {
img <- as.raster((Arg(K) + pi)/(2*pi))
}
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)


# animation ####
# Möbius transformation of order 3
Mob <- function(z, t) {
a <- pi*t/3
((sqrt(3)*cos(a) - sin(a)) * z - 2*sin(a))/
(2*sin(a) * z + sqrt(3)*cos(a) + sin(a))
}

# smooth stair function
xmsinx <- function(x) x - sin(x)
s <- function(x) {
(xmsinx(xmsinx(2*x)) + 4*pi) / (2*pi)
}


# frames
t_ <- seq(-2*pi, pi, length.out = 161)[-1L]
for(i in seq_along(t_)) {
print(i)
img <- colorMap5(Mob(K, s(t_[i])))#, bkgcolor = bkgcol)
#img <- permuteRGB(img, "brg")
svg("x.svg", width = 16, height = 16)
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)
dev.off()
rsvg::rsvg_png(
"x.svg", file = sprintf("zzpic%03d.png", i),
width = 512, height = 512
)
}


# mount animation
library(gifski)
pngs <- Sys.glob("zzpic*.png")
gifski(
pngs,
"Eisenstein6OnSquare.gif",
width = 512, height = 512,
delay = 1/10
)

file.remove(pngs)
35 changes: 35 additions & 0 deletions inst/images/etaDedekind_Cayley.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
library(jacobi)
library(RcppColors)

# the modified Cayley transformation
Phi <- function(z) (1i*z + 1) / (z + 1i)
PhiInv <- function(z) {
1i + (2i*z) / (1i - z)
}

# background color
bkgcol <- "#ffffff"


# make the color mapping
f <- function(x, y) {
z <- complex(real = x, imaginary = y)
tau <- PhiInv(z)
ifelse(
Mod(z) >= 1,
NA_complex_,
eta(tau)
)
}
x <- y <- seq(-1, 1, length.out = 512L)
S <- outer(x, y, Vectorize(f))

img <- colorMap5(S^24)
img <- permuteRGB(img, "gbr")

opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)

78 changes: 78 additions & 0 deletions inst/images/jtheta3_conformalMappingSquare.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
library(jacobi)
library(RcppColors)

# the conformal map
Phi <- function(z) {
-jtheta2(z, 2i) / jtheta3(z, 2i)
}

# background color
bkgcol <- "#ffffff"

# make the color mapping
f <- function(x, y) {
z <- complex(real = x, imaginary = y)
ifelse(
x %in% c(0, 1) || y %in% c(0,1),
NA_complex_,
jacobi:::jtheta3(z,Phi(z*pi))
)
}
x <- y <- seq(0, 1, length.out = 256L)
L <- outer(x, y, Vectorize(f))

img <- colorMap5(1/L)
img <- permuteRGB(img, "brg")

opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)


# animation ####
# Möbius transformation of order 3
Mob <- function(z, t) {
a <- pi*t/3
((sqrt(3)*cos(a) - sin(a)) * z - 2*sin(a))/
(2*sin(a) * z + sqrt(3)*cos(a) + sin(a))
}

# smooth stair function
xmsinx <- function(x) x - sin(x)
s <- function(x) {
(xmsinx(xmsinx(3*x)) + 6*pi) / (4*pi)
}

# frames
t_ <- seq(-2*pi, 2*pi, length.out = 161)[-1L]
#t_ <- seq(0, 3, length.out = 61L)[-1L]
for(i in seq_along(t_)) {
print(i)
img <- colorMap5(Mob(L, s(t_[i])))#, bkgcolor = bkgcol)
img <- permuteRGB(img, "brg")
svg("x.svg", width = 16, height = 16)
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)
dev.off()
rsvg::rsvg_png(
"x.svg", file = sprintf("zzpic%03d.png", i),
width = 512, height = 512
)
}

# mount animation
library(gifski)
pngs <- Sys.glob("zzpic*.png")
gifski(
pngs,
"lambdaOnSquare.gif",
width = 512, height = 512,
delay = 1/11
)

file.remove(pngs)
40 changes: 40 additions & 0 deletions inst/images/klein_Cayley.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
library(jacobi)
library(RcppColors)

# the modified Cayley transformation
Phi <- function(z) (1i*z + 1) / (z + 1i)
disk2H <- function(z) {
1i + (2i*z) / (1i - z)
}
disk2H <- function(z) {
1i * (1-z)/(1+z)
}

# background color
bkgcol <- "#ffffff"

# map the disk to H and calculate kleinj
f <- function(x, y) {
z <- complex(real = x, imaginary = y)
K <- rep(NA_complex_, length(x))
inDisk <- Mod(z) < 1
K[inDisk] <- kleinj(disk2H(z[inDisk]))
K
}
n <- 1024L
x <- y <- seq(-1, 1, length.out = n)
Grid <- expand.grid(X = x, Y = y)
K <- f(Grid$X, Grid$Y)
dim(K) <- c(n, n)
# plot
if(require("RcppColors")) {
img <- colorMap5(K)
} else {
img <- as.raster(1 - abs(Im(K))/Mod(K))
}
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)

109 changes: 109 additions & 0 deletions inst/images/wp_Cayley.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
library(jacobi)
library(RcppColors)

# the modified Cayley transformation
Phi <- function(z) (1i*z + 1) / (z + 1i)
PhiInv <- function(z) {
1i + (2i*z) / (1i - z)
}

# background color
bkgcol <- "#ffffff"


# make the color mapping
f <- function(x, y) {
z <- complex(real = x, imaginary = y)
tau <- PhiInv(z)
ifelse(
Mod(z) >= 1,
NA_complex_,
wp(tau/2, omega=c(0.5, 0.5*tau))
)
}
x <- y <- seq(-1, 1, length.out = 1024L)
W <- outer(x, y, Vectorize(f))

img <- colorMap5(W) # 7, 14 is nice as well (for Im(W)^2 / Mod(W)^2)

opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)



svg("x.svg", width = 16, height = 16)
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)
dev.off()

rsvg::rsvg_png(
"x.svg", "wp_Cayley_cm14.png", width = 512, height = 512
)


# animation Möbius ####

# Möbius transformation of order 2
Mob <- function(z, gamma = -0.5 + 0.5i, t){
h <- sqrt(1-Mod(gamma)^2)
d2 <- h^t * (cos(t*pi/2) + 1i*sin(t*pi/2))
d1 <- Conj(d2)
a <- Re(d1) - 1i*Im(d1)/h
b <- gamma * Im(d2)/h
c <- Conj(b)
d <- Conj(a)
(a*z + b) / (c*z + d)
}

f <- function(x, y, t) {
z <- complex(real = x, imaginary = y)
z <- Mob(z, t = t)
tau <- PhiInv(z)
ifelse(
Mod(z) >= 1,
NA_complex_,
wp(tau/2, omega=c(0.5, 0.5*tau))
)
}


s <- function(x) x

t_ <- seq(0, 2, length.out = 61)[-1L]

for(i in seq_along(t_)) {
print(i)
#MobW <- Mob(W, t = s(t_[i])) # c pas ça qu'il faut faire... il faut refaire un outer
W <- outer(x, y, Vectorize(f), t = s(t_[i]))
img <- colorMap14(Im(W)^2 / Mod(W)^2)#, bkgcolor = bkgcol)
svg("x.svg", width = 16, height = 16)
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
axes = FALSE, xaxs = "i", yaxs = "i", xlab = NA, ylab = NA)
rasterImage(img, 0, 0, 1, 1)
par(opar)
dev.off()
rsvg::rsvg_png(
"x.svg", file = sprintf("zzpic%03d.png", i),
width = 512, height = 512
)
}

# mount animation
library(gifski)
pngs <- Sys.glob("zzpic*.png")
gifski(
pngs,
"wp_Cayley.gif",
width = 512, height = 512,
delay = 1/8
)

file.remove(pngs)

Binary file added inst/images/wp_Cayley.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added inst/images/wp_Cayley_cm14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1ca2eab

Please sign in to comment.