加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

在matlab里面绘制圆锥的方法

(2012-02-13 01:13:42)
标签:

绘制圆锥

杂谈

分类: 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')

作图效果:

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有