Revolving a curve about the y-axis to generate a 3D surface
96 次查看(过去 30 天)
显示 更早的评论
I'm aware that the cylinder() functiond does this for revolutions about the x-axis. But is there a way to do this about the y-axis?
0 个评论
采纳的回答
John D'Errico
2022-5-11
Certainly. Just write the code yourself. Seriously, it is not difficult.
Consider the function y = f(x).
f = @(x) x.*(1-x);
fplot(f,[0,1])
We want to rotate this around the Y axis.
n = 100;
theta = linspace(0,2*pi,n).';
x0 = linspace(0,1,n);
y0 = f(x0);
x = x0.*cos(theta);
z = x0.*sin(theta);
y = repmat(y0,[n,1]);
surf(x,y,z)
xlabel x
ylabel y
zlabel z
view(20,30)
So the y axis lives at (x,z) = (0,0). The curve drawn in the original figure has been rotated around the y axis, producing this sideways cup, with a cusp at the center.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computational Geometry 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!