在matlab里面绘制圆锥的方法

标签:
绘制圆锥杂谈 |
分类: Matlab |
clc
clear
clf
r = 1.0;
h = 2.0;
m = h/r;
[R,A] =
meshgrid(linspace(0.0,r,11),linspace(0,2*pi,41));
X = R .* cos(A);
Y = R .* sin(A);
Z = m*R;
% Cone around the z-axis, point at the origin
mesh(X,Y,Z)
hold on
axis equal
axis([-3 3 -3 3 0 3])
phi = -pi/3;
X1 = X*cos(phi) - Z*sin(phi);
Y1 = Y;
Z1 = X*sin(phi) + Z*cos(phi);
% Previous cone, rotated by angle phi about the y-axis
mesh(X1,Y1,Z1)
theta = pi/4;
X2 = X1*cos(theta) - Y1*sin(theta);
Y2 = X1*sin(theta) + Y1*cos(theta);
Z2 = Z1;
% Second cone rotated by angle theta about the z-axis
mesh(X2,Y2,Z2)
xlabel('x')
ylabel('y')
zlabel('z')
作图效果: