Skip to content

Commit

Permalink
isocuboids eta^24
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Nov 16, 2023
1 parent 69bf3b4 commit f13fe59
Showing 1 changed file with 74 additions and 3 deletions.
77 changes: 74 additions & 3 deletions inst/images/etaDedekind_Cayley.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(jacobi)
library(RcppColors)

# background color
bkgcol <- "#ffffff"
bkgcol <- "#ffffffff"

# map the disk to H and calculate kleinj
f <- function(x, y) {
Expand All @@ -19,7 +19,7 @@ K <- f(Grid$X, Grid$Y)^24
dim(K) <- c(n, n)
# plot
if(require("RcppColors")) {
img <- colorMap5(K)
img <- colorMap5(K, bkgcolor = bkgcol)
} else {
img <- as.raster(1 - abs(Im(K))/Mod(K))
}
Expand All @@ -29,7 +29,78 @@ plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
rasterImage(img, 0, 0, 1, 1)
par(opar)

# isocuboids fork ####
library(isocuboids)
library(ggplot2)
mat <- 1 - abs(Im(K))/Mod(K)
colors <- as.matrix(as.raster(mat))
colors <- colors[, ncol(colors):1L]
mat[is.na(mat)] <- 0
cuboid_matrix2(
70*mat, a1 = 45, a2 = 45, show_axes = FALSE, verbose = TRUE,
cuboid_fill = c(colors)
) + theme_void() +
theme(
panel.background = element_rect(fill = "white", color = "white")
)
ggsave(
"isocuboids_fork_etaDedekindOnCircle.png_gray",
width = 5, height = 5, dpi = 600
)

# with colors ####
img <- colorMap5(K, bkgcolor = "white")
colors <- mat <- as.matrix(img)
colors <- colors[, ncol(colors):1L]
mat <- c(mat)
mat <- mat |> col2rgb() |> rgb2hsv()
mat <- matrix(mat[3L, ], nrow = n, ncol = n)
mat[mat == 1] <- 0
gg <- cuboid_matrix2(
70*mat, a1 = 45, a2 = 45, show_axes = FALSE, verbose = TRUE,
cuboid_fill = c(colors)
) + theme_void() +
theme(
panel.background =
element_rect(fill = "white", color = "white")
)
ggsave(
"isocuboids_fork_etaDedekindOnCircle_colors.png",
gg, width = 5, height = 5, dpi = 600
)

# isocuboids ####
library(isocuboids)
mat <- 1 - abs(Im(K))/Mod(K)
mat[is.na(mat)] <- 0
cuboid_matrix(
70*mat, a1 = 45, a2 = 45, show_axes = FALSE, verbose = TRUE,
cuboid_fill = trekcolors::trek_pal("klingon")
)
ggplot2::ggsave(
"isocuboids_etaDedekindOnCircle_klingon.png",
width = 5, height = 5, dpi = 600
)

# elevated Delaunay ####
mat <- Arg(K) + pi
mat[is.na(mat)] <- 0
library(tessellation)
pts <- expand.grid(X = 1:n, Y = 1:n)
pts$Z <- c(mat)
pts <- as.matrix(pts)
del <- delaunay(pts, elevation = TRUE)

# plotting
library(rgl)
mesh <- del[["mesh"]]
open3d(windowRect = c(100, 100, 612, 356), zoom = 0.6)
aspect3d(1, 1, 20)
shade3d(mesh, color = "limegreen", polygon_offset = 1)



# svg to png ####
svg("x.svg", width = 15, height = 15)
opar <- par(mar = c(0, 0, 0, 0))
plot(NULL, xlim = c(0, 1), ylim = c(0, 1), asp = 1,
Expand All @@ -38,4 +109,4 @@ rasterImage(img, 0, 0, 1, 1)
par(opar)
dev.off()

rsvg::rsvg_png("x.svg", "etaDedekindOnCircle.png", 512, 512)
rsvg::rsvg_png("x.svg", "zzzetaDedekindOnCircle.png", 512, 512)

0 comments on commit f13fe59

Please sign in to comment.