At some point I would like to have the graphic displayed in an interactive web page, but I still don't have my R Shiny server installed.

To do see this yourself, first of all save the following as "save.txt". It defines the viewing point of the 3d graphic.
- Code: Select all
"V1" "V2" "V3" "V4"
"1" 0.89551317691803 -0.445017099380493 -0.00404098257422447 0
"2" 0.00934700295329094 0.00972943194210529 0.999908864498138 0
"3" -0.444936990737915 -0.89546924829483 0.0128725711256266 0
"4" 0 0 0 1
Then run the following code
- Code: Select all
library(rgl)
alpha <- seq(from = 0, to = 180, length = 20)
beta <- alpha
surfQ <- expand.grid(x = alpha, y = beta)
surfQ$z <- with(surfQ, { - cos((x - y)*pi/180)})
corQ <- matrix(surfQ$z, 20 ,20)
surfC <- surfQ
surfC$z <- with(surfC, { - 1 + 2 * abs((x - y)/180)})
corC <- matrix(surfC$z, 20 , 20)
alphaE <- c(0, 90)
betaE <- c(45, 135)
ptsQ <- expand.grid(x = alphaE, y = betaE)
ptsQ$z <- with(ptsQ, { - cos((x - y)*pi/180)})
ptsC <- ptsQ
ptsC$z <- with(ptsC, { - 1 + 2 * abs((x - y)/180)})
persp3d(alpha, beta, corQ, front = "line", back = "line", col = "blue", lit = FALSE, zlab = "")
surface3d(alpha, beta, corC, front = "line", back = "line", col = "green", lit = FALSE)
spheres3d(ptsC$x, ptsC$y, ptsQ$z, col = "blue", radius = 2)
spheres3d(ptsC$x, ptsC$y, ptsC$z, col = "green", radius = 2)
lines3d(rep(ptsC$x[1], 2), rep(ptsC$y[1], 2), c(-1, 1))
lines3d(rep(ptsC$x[2], 2), rep(ptsC$y[2], 2), c(-1, 1))
lines3d(rep(ptsC$x[3], 2), rep(ptsC$y[3], 2), c(-1, 1))
lines3d(rep(ptsC$x[4], 2), rep(ptsC$y[4], 2), c(-1, 1))
save <- read.table("save.txt") ## This line and the next fixes the view-point
par3d(userMatrix = save) ## in the graphic posted here.
## Rotate the picture how you like
## When you like what you see,
## the following lines save the view-point and make a pdf file of the plot
save2 <- par3d("userMatrix")
write.table(save2, "save2.txt")
rgl.postscript("wireframe2.pdf", fmt = "pdf")

