www.gusucode.com > 三维MATLAB图标源码程序 > 三维MATLAB图标源码程序/punctureSurface/tPunctureSurface.m

    % tPunctureSurface.m
%
% Test regimen for punctureSurface.m

% Copyright 2013 The MathWorks, Inc.
clc;
clear;
close all;
warning off;


k = 7;
n = 2*k + 1;
x = linspace(-1,1,n);
thickness = 0.05*max(x);
[x,y] = meshgrid(x);
z = (40/51/0.9)*(max(x(:))-min(x(:)))*membrane(1,k);
h = surf(x,y,z);
set(h,'visible','off');
p = surf2patch(h);
sub = [1:n-1,repmat(n,1,n-1),n:-1:2,ones(1,n-1)];
boundVert = sub2ind(size(z),...
  sub,...
  circshift(sub,[0 n-1]));
boundVert = [boundVert,boundVert(1)];
s = punctureSurface(p, boundVert, 0.5, thickness);
ps = patch(s);
set(ps, ...
    'EdgeColor','none', ...
    'FaceColor',[0.9 0.2 0.2], ...
    'FaceLighting','phong', ...
    'AmbientStrength',0.3, ...
    'DiffuseStrength',0.6, ... 
    'Clipping','off',...
    'BackFaceLighting','lit', ...
    'SpecularStrength',1, ...
    'SpecularColorReflectance',1, ...
    'SpecularExponent',7);
l1 = light('Position',[40 100 20], ...
    'Style','local', ...
    'Color',[0 0.8 0.8]);
l2 = light('Position',[.5 -1 .4], ...
    'Color',[0.8 0.8 0]);
axis vis3d;
axis equal;