I have been using rgl to view xyz point clouds containing topographic data ( with around 10^5 - 10^6 points). It's working well aside from one thing: I would like to be able to zoom into an arbitrary part of the plot. However so far I could only figure out how to zoom into the centre. See the example below -- in this case, I cannot 'zoom-in' to anything other than the central hill in the topography, whereas I would like to be able to zoom to an arbitrary location. Is there a way to get around this? ########################################## # EXAMPLE CODE ########################################## library(rgl) # Make up some topography x=runif(1e+06, min=0,max=1000) y=runif(1e+06, min=0,max=1000) # Elevation with 'hill' in the centre z=sin(x/50.)+cos(y/50.) + 30*exp(-((x-500)^2+(y-500)^2)*0.001) plot3d(x,y,z,col=z+3,aspect=FALSE) # Now try zooming [right mouse button]. I can only zoom into the central hill, not elsewhere. Below are the details of my R Install > sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.93.1098 unstructInterp_0.0-1 rgeos_0.3-6 [4] rgdal_0.8-16 sp_1.0-15 geometry_0.3-4 [7] magic_1.5-6 abind_1.4-0 SearchTrees_0.5.2 [10] roxygen2_4.0.1 loaded via a namespace (and not attached): [1] digest_0.6.4 grid_3.1.1 lattice_0.20-29 Rcpp_0.11.2 [5] stringr_0.6.2 tools_3.1.1 >
rgl zooming to an arbitrary location
3 messages · GD, Duncan Murdoch
On 31/08/2014, 11:12 PM, Gareth Davies wrote:
I have been using rgl to view xyz point clouds containing topographic data ( with around 10^5 - 10^6 points). It's working well aside from one thing: I would like to be able to zoom into an arbitrary part of the plot. However so far I could only figure out how to zoom into the centre. See the example below -- in this case, I cannot 'zoom-in' to anything other than the central hill in the topography, whereas I would like to be able to zoom to an arbitrary location. Is there a way to get around this?
Yes, you can manually set the userMatrix transformation. See ?par3d for a discussion about how rgl figures out what to display. See the example in ?rgl.setMouseCallbacks for some code that does something like what you want. There are plans to make this a little simpler in the next major release, but no definite release date. Duncan Murdoch
########################################## # EXAMPLE CODE ########################################## library(rgl) # Make up some topography x=runif(1e+06, min=0,max=1000) y=runif(1e+06, min=0,max=1000) # Elevation with 'hill' in the centre z=sin(x/50.)+cos(y/50.) + 30*exp(-((x-500)^2+(y-500)^2)*0.001) plot3d(x,y,z,col=z+3,aspect=FALSE) # Now try zooming [right mouse button]. I can only zoom into the central hill, not elsewhere. Below are the details of my R Install
> sessionInfo()
R version 3.1.1 (2014-07-10) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.93.1098 unstructInterp_0.0-1 rgeos_0.3-6 [4] rgdal_0.8-16 sp_1.0-15 geometry_0.3-4 [7] magic_1.5-6 abind_1.4-0 SearchTrees_0.5.2 [10] roxygen2_4.0.1 loaded via a namespace (and not attached): [1] digest_0.6.4 grid_3.1.1 lattice_0.20-29 Rcpp_0.11.2 [5] stringr_0.6.2 tools_3.1.1
>
______________________________________________ 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.
Fantastic -- the pan3d function in the example for rgl.setMouseCallbacks solves the problem. For illustration: ################## library(rgl) # Get the pan3d function by running this rgl example [ignore the error caused by not having an open rgl device] example(rgl.setMouseCallbacks) #Make up some topography x=runif(1e+06, min=0,max=1000) y=runif(1e+06, min=0,max=1000) # Elevation with 'hill' in the centre z=sin(x/50.)+cos(y/50.) + 30*exp(-((x-500)^2+(y-500)^2)*0.001) plot3d(x,y,z,col=z+3,aspect=FALSE) pan3d(3) # This makes my 'middle' mouse button function like pan
On 02/09/14 06:25, Duncan Murdoch wrote:
On 31/08/2014, 11:12 PM, Gareth Davies wrote:
I have been using rgl to view xyz point clouds containing topographic data ( with around 10^5 - 10^6 points). It's working well aside from one thing: I would like to be able to zoom into an arbitrary part of the plot. However so far I could only figure out how to zoom into the centre. See the example below -- in this case, I cannot 'zoom-in' to anything other than the central hill in the topography, whereas I would like to be able to zoom to an arbitrary location. Is there a way to get around this?
Yes, you can manually set the userMatrix transformation. See ?par3d for a discussion about how rgl figures out what to display. See the example in ?rgl.setMouseCallbacks for some code that does something like what you want. There are plans to make this a little simpler in the next major release, but no definite release date. Duncan Murdoch
########################################## # EXAMPLE CODE ########################################## library(rgl) # Make up some topography x=runif(1e+06, min=0,max=1000) y=runif(1e+06, min=0,max=1000) # Elevation with 'hill' in the centre z=sin(x/50.)+cos(y/50.) + 30*exp(-((x-500)^2+(y-500)^2)*0.001) plot3d(x,y,z,col=z+3,aspect=FALSE) # Now try zooming [right mouse button]. I can only zoom into the central hill, not elsewhere. Below are the details of my R Install
> sessionInfo()
R version 3.1.1 (2014-07-10) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.93.1098 unstructInterp_0.0-1 rgeos_0.3-6 [4] rgdal_0.8-16 sp_1.0-15 geometry_0.3-4 [7] magic_1.5-6 abind_1.4-0 SearchTrees_0.5.2 [10] roxygen2_4.0.1 loaded via a namespace (and not attached): [1] digest_0.6.4 grid_3.1.1 lattice_0.20-29 Rcpp_0.11.2 [5] stringr_0.6.2 tools_3.1.1
>
______________________________________________ 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.