有趣的surface函数

时间:2022-03-31 14:02:57
整理文档时偶然发现了在暑假时玩的一个有趣的surface函数,分享给大家。

在心形图形上贴上图片:
clear
clc
[c,f]=meshgrid(0:0.1:pi,0:0.1:2*pi);

x=sin(c).*cos(f);
y=sin(c).*sin(f);
z=cos(c);
z=z;

y=2.*y;
x=5.*x;
z=1.3.*z;

[x1,y1,z1]=cart2pol(x,y,z); 
   
x1=x1+pi/4;
x4=x1-pi/2;

[x2,y2,z2]=pol2cart(x1,y1,z1);
[x3,y3,z3]=pol2cart(x4,y1,z1);

q=find(y3<0);w=size(q);
for i=1:w
    v(i)=mod(q(i),63);
    if v(i)==0
        v(i)=63;
    end 
    u(i)=(q(i)-v(i))/63;
end

for i=1:w    
    if v(i)==0
        v(i)=63;
    end    
end

for i=1:w
   x3(v(i),u(i))=0;
   y3(v(i),u(i))=0;
   z3(v(i),u(i))=0;
end

q=find(y2>0.2);w=size(q);
for i=1:w
    v(i)=mod(q(i),63);
    u(i)=(q(i)-v(i))/63;
end

for i=1:w
    if v(i)==0
        v(i)=63;
    end 
end

for i=1:w
   x2(v(i),u(i))=0;
   y2(v(i),u(i))=0;
   z2(v(i),u(i))=0;
end

mesh(x2,y2,z2)
hold on
mesh(x3,y3,z3)

% x0=imread('C:\Users\acer\Desktop\6.jpg');

% surface(x2,y2,z2,x0,'FaceColor','texturemap','EdgeColor',...
%  'none','CDataMapping','direct')
% hold on
% surface(x3,y3,z3,x0,'FaceColor','texturemap','EdgeColor',...
%  'none','CDataMapping','direct')

view(3); daspect([1 1 1]);
grid on
view(47,42)


有趣的surface函数

[asd1]

有趣的surface函数


[asd2]有趣的surface函数