数字图像处理-设计生成一个半球
1 实验题目
设计生成一个半球(matlab)。
2 程序源代码
%Hemisphere
clear,clc,close all
%Sphere radius
R=1;
%Set grid number
n=30;
theta = (-n:2:n)/n*pi;
phi = ([0,0:2:n])'/n*pi/2;
cosphi = cos(phi); cosphi(1) = 0; cosphi(end) = 0;
sintheta = sin(theta); sintheta(1) = 0; sintheta(end) = 0;
x = R*cosphi*cos(theta);
y = R*cosphi*sintheta;
z = R*sin(phi)*ones(1,n+1);
%The figure color is beach color
colormap([0.77 0.61 0.4]);
surf(x,y,z);
%Set title, etc
title('Hemisphere');
set(gca,'xticklabel',[])
set(gca,'yticklabel',[])
set(gca,'zticklabel',[])