On 12/04/2014, 1:03 PM, Duncan Murdoch wrote:
On 12/04/2014, 11:19 AM, Roland Rau wrote:
Dear all,

I am using package rgl and I want to change the position where I "stand".
Maybe a small example might clarify what I am looking for:


# Begininng of explanatory example
library(rgl)
data(volcano)

# the example ?rgl.surface
y <- 2 * volcano
x <- 10 * (1:nrow(y))
z <- 10 * (1:ncol(y))
ylim <- range(y)
ylen <- ylim[2] - ylim[1] + 1
colorlut <- terrain.colors(ylen)
col <- colorlut[ y-ylim[1]+1 ]

rgl.open()
rgl.surface(x, z, y, color=col, back="lines")
## now I have the nice volcano surface
## with rgl.viewpoint I can change the elevation
## and the angle from where I look at the rgl.surface
# example of ?rgl.viewpoint
start <- proc.time()[3]
while ((i <- 36*(proc.time()[3]-start)) < 360) {
    rgl.viewpoint(i,i/4);
}
# End of explanatory example

What I am looking for (in this example) would be a way for me to "stand"
on the crater of the volcano, looking in a specific direction. Is there
something like a function where I can specify my coordinates (x,y,z) and
angle and a zoom factor?

I think you could hack something like that (see the description in
?par3d of how rendering is accomplished), but there's currently no
support for it, and it wouldn't be easy, as currently P and M in that
description are read-only quantities computed indirectly.  So you'd have
to essentially trick rgl into producing the P matrix corresponding to
the viewing position you want.

I am currently working on some changes that might make this easier, but
they likely aren't going to be released for several months.

If you are interested in looking at this, a rudimentary version is now available on a non-released branch of rgl. Currently you can specify the observer location, but not the direction of view: but since you can rotate the model by mouse or otherwise, that allows the direction to change.

I will likely implement the more general version before release.

If you are interested in trying this out, let me know how you'd like to receive it. You can get the source from svn on R-forge (get the subscenes branch), or I could package it up and email it to you, if you tell me what form you want (source tarball, binary for which R version, etc.)

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.

Reply via email to