将 2D 图像转换为 3D

Converting 2D images to 3D

我试图通过绕轴旋转 2D 图像将它们转换为 3D(就像从圆到球体)。 目前我的问题是,假设我在一个变量中有两个函数 f(x) 和 g(x)。我想绘制函数图并使用旋转来获取 3D 图。根据 3D 图,我会区分两者。

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

您可以使用 R 中的 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")

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