Hello,

I'm trying to add a colorbar to a 3d map using rgl.
For this purpose, I draw the map in a similar way of persp3d example : 

lat <- matrix(seq(90,-90, len=50)*pi/180, 50, 50, byrow=TRUE)
long <- matrix(seq(-180, 180, len=50)*pi/180, 50, 50)

r <- 6378.1 # radius of Earth in km
x <- r*cos(lat)*cos(long)
y <- r*cos(lat)*sin(long)
z <- r*sin(lat)

open3d()
persp3d(x, y, z, col="white", 
       texture=system.file("textures/worldsmall.png",package="rgl"), 
       specular="black", axes=FALSE, box=FALSE, xlab="", ylab="", zlab="",
       normal_x=x, normal_y=y, normal_z=z)

then I add a basic colorbar drawing several 3d colored cubes and label them 
using text3d

shapelist3d(cube3d(), x,y,z, col=grey.colors(5),add=T)
text3d(x+dx,y+dy,z+dz,"label")

The results is ok (if someone know a better way to do it, please tell me how)
Now I would like to improve the result and in particular I would like to have a 
static colorbar (stick to a plan parallel to the window) when I rotate the 
"earth".
My first idea is to redefine the rotation button using  rgl.setMouseCallbacks 
and then pop and redraw colorbar in update fonction of   rgl.setMouseCallback.
1/ Is it a good idea ?
2/ How to get angle and x,y,z value  to compute rotationMatrix(angle,x,y,z) 
from window coordinates ?
3/ Is it possible, in the same idea,  to have a static colorbar when I zoom on 
a earth region ?

I hope my question is clear (as you see I am not a  native english speaker) and 
thank you for your answers.
                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to