On 19/06/2014, 1:00 PM, Céline b wrote: > 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.
Unless you are in a real hurry, I wouldn't recommend doing it this way. I am making some additions to rgl that will make this much easier, though it is likely a month or so before these reach CRAN. If you would like to try the changes before release, you can find them on the rgl page on R-forge: https://r-forge.r-project.org/projects/rgl/ The new changes are in the "subscenes" branch of the svn tree. This is not so easy to use, so if you let me know the platform and R version you are using, I'd be happy to build you a copy that you can install. Duncan Murdoch ______________________________________________ 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.