如何画一个带有双色粒子的水晶球 [英] How to draw a crystal ball with two-color particles inside

查看:181
本文介绍了如何画一个带有双色粒子的水晶球的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想着关闭的可能性。我需要画一个水晶球,红色和蓝色粒子随机放置。我想我必须去与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 -to-OpenGL interface):

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

img src =https://i.stack.imgur.com/CZF3G.pngalt =输入图片说明here>>

这篇关于如何画一个带有双色粒子的水晶球的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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