Generating a 3D plot by revolution of a curve

后端 未结 1 1118
礼貌的吻别
礼貌的吻别 2021-01-21 19:55

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

I\'ve tried using

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

th

相关标签:
1条回答
  • 2021-01-21 20:43

    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
    

    EDIT

    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
    

    enter image description here

    0 讨论(0)
提交回复
热议问题