Camarda, Carlo Giovanni
2009-Apr-08 15:01 UTC
[R] persp3d and rgl.viewpoint for rotating 3D plots
Dear R-users, within the rgl-package, I would have a question about the usage of persp3d in combination of rgl.viewpoint. I am not able to figure out how to let a 3D plot rotating around likewise the example in ?rgl.viewpoint. It seems that when I use persp3d(...) I see something on my screen, which is different from what I get when it's rotating. Is there any different behavior between shade3d and persp3d? Please find below a simple example. Actually, my final aim is to save each of the rotating graphs for creating a "clip". I commented below what I would use later on, but is there any way to do it better? Thanks a lot for your help, Carlo Giovanni Camarda library(rgl) # simplified version from help(rgl.viewpoint) shade3d(oh3d()) coo <- 1:360 for(i in 1:length(coo)) { rgl.viewpoint(coo[i]) #filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="") #rgl.snapshot(filename) } # simple persp3d adaption f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r } x <- seq(-10, 10, length= 30); y <- x z <- outer(x, y, f) persp3d(x, y, z) coo <- 1:360 for(i in 1:length(coo)) { rgl.viewpoint(coo[i]) #filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="") #rgl.snapshot(filename) } ----------------------------------------------------- Dr. Carlo Giovanni Camarda Research Scientist Max Planck Institute for Demographic Research Laboratory of Statistical Demography Konrad-Zuse-Straße 1 18057 Rostock - Germany Phone: +49 (0)381 2081 172 Fax: +49 (0)381 2081 472 camarda@demogr.mpg.de http://www.demogr.mpg.de/en/staff/camarda/default.htm ----------------------------------------------------- ---------- This mail has been sent through the MPI for Demographic ...{{dropped:10}}
On 4/8/2009 11:01 AM, Camarda, Carlo Giovanni wrote:> Dear R-users, > > within the rgl-package, I would have a question about the usage of persp3d in combination of rgl.viewpoint. > I am not able to figure out how to let a 3D plot rotating around likewise the example in ?rgl.viewpoint. It seems that when I use persp3d(...) I see something on my screen, which is different from what I get when it's rotating. Is there any different behavior between shade3d and persp3d? > Please find below a simple example. > > Actually, my final aim is to save each of the rotating graphs for creating a "clip". I commented below what I would use later on, but is there any way to do it better?Take a look at ?movie3d. I think it does what you want. Duncan Murdoch> > Thanks a lot for your help, > Carlo Giovanni Camarda > > > library(rgl) > # simplified version from help(rgl.viewpoint) > shade3d(oh3d()) > coo <- 1:360 > for(i in 1:length(coo)) { > rgl.viewpoint(coo[i]) > #filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="") > #rgl.snapshot(filename) > } > > # simple persp3d adaption > f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r } > x <- seq(-10, 10, length= 30); y <- x > z <- outer(x, y, f) > persp3d(x, y, z) > coo <- 1:360 > for(i in 1:length(coo)) { > rgl.viewpoint(coo[i]) > #filename <- paste("pic", formatC(i,digits=1,flag="00"), ".png", sep="") > #rgl.snapshot(filename) > } > > > > ----------------------------------------------------- > Dr. Carlo Giovanni Camarda > Research Scientist > Max Planck Institute for Demographic Research > Laboratory of Statistical Demography > Konrad-Zuse-Stra?e 1 > 18057 Rostock - Germany > Phone: +49 (0)381 2081 172 > Fax: +49 (0)381 2081 472 > camarda at demogr.mpg.de > http://www.demogr.mpg.de/en/staff/camarda/default.htm > ----------------------------------------------------- > > > ---------- > This mail has been sent through the MPI for Demographic ...{{dropped:10}} > > > > ------------------------------------------------------------------------ > > ______________________________________________ > R-help at 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.
Maybe Matching Threads
- two plots side-by-side with persp3d(rgl)
- Save parameters from optim during iteration procedure
- optim with specific constraints on possible values
- How to add/draw a persp3d graph to a plot with an existing surface/graph
- RGL plot : lighting problem when triangle3d and persp3d are used in the same plot