Pergunta

I have a set of data, looks like:

    x   y   z
1   1   2   1
2   3   5   7
3   -3  2   4
4   -2  1   1

so each row record the dot coordinate in a 3-D space. I want to plot all the dot as points except for one, say no.15 as a translucent sphere, with radius I can set. Then I can see from the plot that which of those points in the data are included in the sphere. I'm using RGL package right now and did the following:

> open3d()
> plot3d(readin,col=3,type="p")
> plot3d(readin[15,],col=2,add=T,type="s",radius=0.1)

So the first plot command plotted the whole set as scatter plots and the second plot command picked the 15th row of the data and plot it as a sphere and add it to the previous canvas. I just wondering if I can make the sphere translucent so that I can see which dots a included in the sphere which means those dots are very near to the one I select.

Is there a way to do this by RGL Or you can provide me another ways to complete this task?

Thanks!

Foi útil?

Solução

I think what you are looking for is the argument alpha.

Example

df <- data.frame(x=c(1,3,-3,-2), y=c(2,5,2,1),z=c(1,7,4,1))

library(rgl)
open3d()
plot3d(df,col=3,type="p", radius=0.5)
plot3d(df,col=rgb(1,0,0.3),alpha=0.5, add=T,type="s",radius=1)

enter image description here

Outras dicas

You can plot transparent spheres using the alpha argument to spheres3d. You can rotate the plot to move the box line behind the sphere to prove it's transparent.

 spheres3d(dat[4,],col=rgb(1,0,0), alpha=0.9)  # transparent red.

(I tried to do it with the alpha argument to rgb but it failed.)

If you just want to find out which points are within a certain radius of point 15 then you can calculate the Euclidean distance from each point to point 15 and see which of those distances are less than the radius. No plotting needed (though you could plot those points as a different color to highlight them. The dist function is one way to compute the distances, or it is simple to program yourself.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top