On 4/8/2009 11:47 AM, Camarda, Carlo Giovanni wrote:
Dear Duncan,

thanks for your prompt reply. I was tempted to use movie3d, but below I copied what I get on my PC. Then, I have ImageMagick installed and, though I set convert equal to FALSE, I was not able to find where the function writes the .png files. Maybe I lack experience in managing such complex functions, but I must confess that I have quite some hard time to grasp info from help(movie3d).

Presumably ImageMagick is not on your PATH, which is why movie3d() failed to find it. It writes the image files to the directory given by the dir parameter, which defaults to tempdir(). tempdir() returns a session-specific temporary directory, which R will try to clear at the end of a session.

Duncan Murdoch


Thanks in advance for any help,
Carlo Giovanni


library(rgl)
# set data
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)
# set working directory
setwd("U:\\movie")
dir() # check
character(0)
# plot
persp3d(x, y, z)
movie3d(spin3d(), duration=5, convert=TRUE)
Writing movie000.png [...] Writing movie050.png Error in movie3d(spin3d(), duration = 5, convert = TRUE) : ImageMagick not found
dir() # check again
character(0)
movie3d(spin3d(), duration=5, convert=FALSE)
Writing movie000.png [...] Writing movie050.png
dir() # check again ??
character(0)


version
_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 8.1 year 2008 month 12 day 22 svn rev 47281 language R version.string R version 2.8.1 (2008-12-22)


-----Original Message-----
From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] Sent: Wednesday, April 08, 2009 5:13 PM
To: Camarda, Carlo Giovanni
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] persp3d and rgl.viewpoint for rotating 3D plots

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
cama...@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@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.


----------
This mail has been sent through the MPI for Demographic Research.  Should you 
receive a mail that is apparently from a MPI user without this text displayed, 
then the address has most likely been faked. If you are uncertain about the 
validity of this message, please check the mail header or ask your system 
administrator for assistance.


______________________________________________
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