水晶球怎么画里面有两种颜色的颗粒 [英] How to draw a crystal ball with two-color particles inside

查看:9
本文介绍了水晶球怎么画里面有两种颜色的颗粒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是提出一个可能关闭的想法.我需要画一个水晶球,其中红色和蓝色粒子随机分布.我想我必须使用 Photoshop,甚至尝试在图像中制作球,但由于这是用于研究论文并且不必花哨,我想知道是否有任何方法可以使用 R、matlab 或任何其他语言.

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.

推荐答案

在 R 中,使用 rgl 包(R-to-OpenGL 接口):

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")

这篇关于水晶球怎么画里面有两种颜色的颗粒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆