0

我正在尝试将尺寸为 xy 的两个圆周与 3d 绘图一起绘制并为两个圆的交点着色,我该怎么做?

# objective function
x <- seq(-1,1,.1)
y <- seq(-1,1,.1)
z <- x^2 + y^2

library(scatterplot3d)
library(plotrix)
scatterplot3d(x,y,z,pch=19,color="royalblue4")
draw.circle (1,1,1)
draw.circle (1,-1,1)
4

1 回答 1

1

我不是很喜欢数学的东西,但我会作为答案发布,因为它可能有用,而且太大而无法发表评论。不过,如果我发表废话,请原谅我的无知。

#your data
library(scatterplot3d)
x <- seq(-1,1,.1)
y <- seq(-1,1,.1)
z <- x^2 + y^2

ang = 60 #angle of the 3D plot. experiment with different values

#your 3D plot, with extended xx', yy' limits
sp3d <- scatterplot3d(x, y, z, pch=19, color="royalblue4", 
           xlim = c(-1, 3), ylim = c(-3, 3), angle = ang)

#to use parametric equations of circles
f <- seq(-2*pi, 2*pi, 0.1)

#circle1
sp3d$points(x = 1 + 1*cos(f), y = 1 + 1*sin(f), z = rep(0, length(f)), type = "l")
#circle2
sp3d$points(x = 1 + 1*cos(f), y = -1 + 1*sin(f), z = rep(0, length(f)), type = "l")

情节是:

sp3d

于 2013-10-26T09:53:00.553 回答