一年一度的万圣节要到了,正好这天在Linkedin上看到Mathworks发的帖子,用Matlab画一个南瓜,很是有趣。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | % Pumpkin [X,Y,Z]=sphere(200); R=1-(1-mod(0:.1:20,2)).^2/12; x=R.*X; y=R.*Y; z=Z.*R; c=hypot(hypot(x,y),z)+randn(201)*.03; surf(x,y,(.8+(0-(1:-.01:-1)'.^4)*.3).*z,c, 'FaceColor', 'interp', 'EdgeColor', 'none') % Stem s = [ 1.5 1 repelem(.7, 6) ] .* [ repmat([.1 .06],1,10) .1 ]'; [t, p] = meshgrid(0:pi/15:pi/2,0:pi/20:pi); Xs = -(.4-cos(p).*s).*cos(t)+.4; Zs = (.5-cos(p).*s).*sin(t) + .55; Ys = -sin(p).*s; surface(Xs,Ys,Zs,[],'FaceColor', '#008000','EdgeColor','none'); % Style colormap([1 .4 .1; 1 1 .7]) axis equal box on material([.6 1 .3]) lighting g camlight |
% Pumpkin [X,Y,Z]=sphere(200); R=1-(1-mod(0:.1:20,2)).^2/12; x=R.*X; y=R.*Y; z=Z.*R; c=hypot(hypot(x,y),z)+randn(201)*.03; surf(x,y,(.8+(0-(1:-.01:-1)'.^4)*.3).*z,c, 'FaceColor', 'interp', 'EdgeColor', 'none') % Stem s = [ 1.5 1 repelem(.7, 6) ] .* [ repmat([.1 .06],1,10) .1 ]'; [t, p] = meshgrid(0:pi/15:pi/2,0:pi/20:pi); Xs = -(.4-cos(p).*s).*cos(t)+.4; Zs = (.5-cos(p).*s).*sin(t) + .55; Ys = -sin(p).*s; surface(Xs,Ys,Zs,[],'FaceColor', '#008000','EdgeColor','none'); % Style colormap([1 .4 .1; 1 1 .7]) axis equal box on material([.6 1 .3]) lighting g camlight
英文:Draw a Pumpkin using Matlab
Mathwork Matlab
英国万圣节/Halloween
GD Star Rating
loading...
本文一共 53 个汉字, 你数一下对不对.loading...
上一篇: 从今年夏天开始洗冷水澡
下一篇: DirectX 诊断工具 dxdiag 查看系统信息
扫描二维码,分享本文到微信朋友圈