Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a crystal ball with two-color particles inside

I am just throwing an idea with possibility of closing. I need to draw a crystal ball in which red and blue particles randomly locate. I guess I have to go with photoshop, and even tried to make the ball in an image but as this is for research paper and does not have to be fancy, I wonder if there is any way to program with R, matlab, or any other language.

like image 386
Tae-Sung Shin Avatar asked Oct 23 '12 15:10

Tae-Sung Shin


1 Answers

In R, using the rgl package (R-to-OpenGL interface):

library(rgl) n <- 100 set.seed(101) randcoord <- function(n=100,r=1) {     d <- data.frame(rho=runif(n)*r,phi=runif(n)*2*pi,psi=runif(n)*2*pi)     with(d,data.frame(x=rho*sin(phi)*cos(psi),                       y=rho*sin(phi)*sin(psi),                       z=rho*cos(phi))) }     ## http://en.wikipedia.org/wiki/List_of_common_coordinate_transformations with(randcoord(50,r=0.95),spheres3d(x,y,z,radius=0.02,col="red")) with(randcoord(50,r=0.95),spheres3d(x,y,z,radius=0.02,col="blue")) spheres3d(0,0,0,radius=1,col="white",alpha=0.5,shininess=128) rgl.bg(col="black") rgl.snapshot("crystalball.png") 

enter image description here

like image 192
Ben Bolker Avatar answered Sep 25 '22 03:09

Ben Bolker