函数程序:
%绘制以圆心,长轴短轴半径,以及偏角,以及高度为未知数的半椭球
function surf_ellipse(xe,ye,a,b,aerfa,h)
%a表示的是x轴半径,b表示y轴半径,[xe,ye]为圆形坐标,h椭球最大高度
[theta,phi]=meshgrid(0:10:360,0:10:90);%全椭球为[-90:10:90]
aerfa=aerfa/180*pi;
x=(a*cos(theta*pi/180)*cos(aerfa)-b*sin(theta*pi/180)*sin(aerfa)).*cos(phi*pi/180)+xe;
y=(a*cos(theta*pi/180)*sin(aerfa)+b*sin(theta*pi/180)*cos(aerfa)).*cos(phi*pi/180)+ye;
z=h*sin(phi*pi/180);
surf(x,y,z)
axis equal
end
脚本:
例:绘制圆形为(0,0),短轴半径200,长轴半径300,偏角20,高度300的半椭球
surf_ellipse(0,0,200,300,20,300)
结果图像如下: