2015-06-10 232 views
1

我试图通过围绕轴旋转2D图像(如圆圈到球体)来将2D图像转换为3D。 目前我的问题是,假设我在一个变量中有两个函数f(x)和g(x)。我想制作一个功能图并使用旋转来获得3D图。基于3D图,我将区分这两者。将2D图像转换为3D

我认为一种方法可能是为旋转后的新函数计算精确表达式,但对于不太合理的函数,这在计算上可能是不可行的。 有人可以请建议一种方法来使用合适的软件来做到这一点?

+0

你的意思是什么样的功能? – kezzos

+0

你看过grDevices吗?它有'trans3d',也许有相反的地方。 – Robert

+0

什么是旋转轴? – jenesaisquoi

回答

1

你可以在读该使用rgl包(接口OpenGL的)和turn3d功能

## Define a function (ys must be positive, we are spinning about x-axis) 
f <- function(x) 2*exp(-1/2*x) * (cos(pi*x) + sin(pi*x)) + 2 
xs <- seq(0, 10, length=1000) 
plot(xs, f(xs), type="l") 

enter image description here

## Rotate about the x-axis 
library(rgl) 
res <- turn3d(xs, f(xs)) 
plot3d(res, alpha=.5) 
snapshot3d("temp.png") 

enter image description here