rgl

rgl vector diagrams: show right angles for orthogonal vectors

笑着哭i 提交于 2019-12-01 05:56:20
In the matlib package, https://github.com/friendly/matlib/ , I have a function, vectors3d() to draw geometric vector diagrams. The following code gives an example figure showing a unit vector "J" and some of its projections on the X, Y, Z axes. In the calls to segments3d , each argument is a 2 x 3 matrix giving start/end coordinates. if (!require(matlib)) devtools::install_github(friendly/matlib) library(matlib) library(rgl) vec <- rbind(diag(3), c(1,1,1)) rownames(vec) <- c("X", "Y", "Z", "J") open3d() vectors3d(vec, col=c(rep("black",3), "red"), lwd=2) # draw the XZ plane, whose equation is

plot3D - having two plots at once

大城市里の小女人 提交于 2019-12-01 02:59:05
plot3d() produces a 3d plot that I can twist around and rotate. But when I call plot3d() again, the previous plot goes away and is replaced by this one. How can I make it so that a new XQuartz window opens up rather than the old window being replaced by the new 3d plot. Essentially, I want two 3d plots opened at once. like this: library(rgl) open3d() x <- sort(rnorm(1000)) y <- rnorm(1000) z <- rnorm(1000) + atan2(x,y) plot3d(x, y, z, col=rainbow(1000)) open3d() x <- sort(rnorm(20)) y <- rnorm(20) z <- rnorm(20) + atan2(x,y) plot3d(x, y, z, col=rainbow(20)) The key here is calling open3d

shiny app rglwidget get userMatrix to generate another plot with same rotation

≡放荡痞女 提交于 2019-11-30 22:50:55
I have a shiny app and integrate an rgl 3d-plot into it. I am using renderRglwidget from the rglwidget package to insert the rgl graphics using webgl into my shiny app. In the app the user can rotate the graphic. Now I want to save the rotation state, hence the userMatrix or modelMatrix to later generate a similar plot with the same rotation as the user left the previous graph. Here I read something about java variables storing the userMatrix and other parameters. Can I access them from within my shiny app (in R code)? In rgl itself I can use rotationMatrix <- rgl.projection()$model or

How to render scatter3d inside shiny page instead of popup

て烟熏妆下的殇ゞ 提交于 2019-11-30 18:52:03
问题 I'm looking at implementing 3D interactive plots in my shiny App, and so far I've been using plotly. However, plotly has one major disadvantage, it's extremely slow when rendering. I've done checks, and the whole creation of updated outplot$plot <- renderPlotly ({.....}) and plotlyOutput("plot") takes less than 0.5 seconds, despite the large data set involved. This is a know issue for years but still seems to be current. Hence, I'm looking to use a package called car, also because it has many

How to increase smoothness of spheres3d in rgl

我们两清 提交于 2019-11-30 14:15:48
When I use rgl::spheres3d() , the rendered spheres have clunky facetted edges. spheres = data.frame(x = c(1,2,3), y = c(1,3,1), color = c("#992222" , "#222299", "#229922")) open3d() spheres3d(spheres$x, spheres$y, radius = 1, color = spheres$color) Setting material3d(smooth = TRUE, line_antialias = TRUE) does not improve this. Increasing the radius does not help either. Is there any way to increase the smoothness with which they are drawn? Mike Wise Expanding on cuttlefish44's excellent answer , I found a parameterization that works better - i.e. it has no defect at the poles (the black

3D Plotting in R - Using a 4th dimension of color

爱⌒轻易说出口 提交于 2019-11-30 03:58:53
I am using the plot3d function to make a 3d plot in my R script. I'd like to add a 4th dimension, which will be color. How can I do this? Specifically, assume I have the following code: plot3d(x, y, z, col=cols, size=2, type='s') how would I populate cols based on a vector of values acting as my 4th dimension. Just make a colormap, and then index into it with a cut version of your c variable: x = rnorm(100) y = rnorm(100) z = rnorm(100) c = z c = cut(c, breaks=64) cols = rainbow(64)[as.numeric(c)] plot3d(x,y,z,col=cols) 来源: https://stackoverflow.com/questions/8013217/3d-plotting-in-r-using-a

3d surface plot with xyz coordinates

a 夏天 提交于 2019-11-29 20:09:10
I am hoping someone with experience can help in how one prepares the shape files from xyz data. A great example of a well-prepared dataset can be seen here for the comet Churyumov–Gerasimenko, although the preceding steps in creating the shape file are not provided. I'm trying to better understand how to apply a surface to a given set of XYZ coordinates. Using Cartesian coordinates is straight forward with the R package "rgl", however shapes that wrap around seem more difficult. I found the R package geometry , which provides an interface to QHULL functions. I tried using this to calculate

How can I add rows to an R data frame every other row?

我们两清 提交于 2019-11-29 10:39:23
Brief: how can I add m rows to my m X n data frame, where each new row is inserted after each existing row? I will essentially copy the existing row, but make a change to one variable. More detail: in reference to another question , I think I can do what I want with rgl's segments3d function. I have a set of x,y,z points, but these are just one end point of a set of line segments. The other end point is so many metres away in the Z dimension, given as a fourth variable: X,Y,Z,Z_Length; in my terminology it's easting,northing,elevation,length. According to the rgl docs, "Points are taken in

Adding a legend to an rgl 3d plot

走远了吗. 提交于 2019-11-29 10:24:33
I am trying to draw a 3d plot using rgl with colors legend indicating which color refer to which class (called 'cut.rank'): plot3d( data.focus$normalized.price_shipping, data.focus$seller_feedback_score_rank, data.focus$seller_positive_feedback_percent_rank, col=as.factor(data.focus$cut.rank), size=1, type='s', xlab = 'Normalized Price', ylab = 'Seller Feedbacl Score Rank', zlab = 'Seller Positive Feedback Percent Rank', main = 'Rank By Price, Feedback score and Positive Feedback Score', sub = 'Search Rank has 3 colored levels', colkey = list(length = 0.5, width = 0.5, cex.clab = 0.75)) ) But

Installing “rgl” package in R, Mac OSX El Captian

柔情痞子 提交于 2019-11-29 06:49:21
I'm new to programming in R so I apologise in advance if I seem naive. I want to be able to do some principal components analysis on my data in 3D. I read that the "pca3d" function is good for this, but I need to download the "rgl" library. When I use install.packages it asks: install.packages("rgl") There is a binary version available but the source version is later: binary source needs_compilation rgl 0.95.1201 0.95.1367 TRUE Do you want to install from sources the package which needs compilation? y/n: n I have tried installing it as both binary and source, but nothing seems to work. If I