2015-06-10 229 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