通过曲线旋转生成3D图 [英] Generating a 3D plot by revolution of a curve

查看:68
本文介绍了通过曲线旋转生成3D图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试旋转2D曲线以生成3D表面图.

I'm trying to revolve a 2D curve to generate a 3D surface plot.

我尝试使用

[X,Z,Y] = cylinder(u);
surf(X,Y,Z), axis square

但是,这使我的曲线绕错误的轴旋转.如何更改轴?

this, however, revolves my curve around the wrong axis. How do I go about changing the axis?

非常感谢.

推荐答案

要旋转圆柱轴,只需更改X,Y和Z的顺序即可.

To rotate the axis of the cylinder, you can simply change the order of X, Y, and Z.

[X,Y,Z] = cylinder(u);

surf(X,Y,Z) %# rotation around Z
surf(Z,X,Y) %# rotation around X
surf(Y,Z,X) %# rotation around Y

编辑

要更改曲线的旋转轴,必须计算曲面.例如,要使y = sin(alpha)alpha = 0:0.1:pi围绕y轴旋转,您可以编写

To change the axis of rotation of your curve, you have to calculate the surface. For example, to rotate y = sin(alpha) with alpha = 0:0.1:pi around the y-axis, you can write

r = 0:0.1:pi;
z = sin(r);
theta = 0:pi/20:2*pi;
xx = bsxfun(@times,r',cos(theta));
yy = bsxfun(@times,r',sin(theta));
zz = repmat(z',1,length(theta));
dfig,surf(xx,yy,zz)
axis equal

这篇关于通过曲线旋转生成3D图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆