landscape.m

来自「利用MATLAB作的分形地形源代码」· M 代码 · 共 35 行

M
35
字号
function landscape(n, factor, flag)

% landscape(N,FACTOR,FLAG) draws a fractal landscape 
% which is given by a recursively computed mountain in 3D -
% with or without randomisation.
% n gives the number of iterations; factor is the contraction factor;
% flag indicates whether the height difference is chosen randomly - 
% flag = 0 is random, every other flag gives the deterministic picture.
% 
% landscape(N,FACTOR) plots a random mountain (flag = 0).
%
% landscape uses n = 6 and factor = 0.4 in addition.

% default settings
if (nargin < 3)
    flag = 0;
end
if (nargin < 2)
    n = 6;
    factor = 0.4;
end

% loading the colormap
load mat2;
colormap (map);

% compute the co-ordinates of the mountain
[x1,x2,y] = landscape_matrix(n, factor, flag);

% plot the results
fill3(x1', x2', y', y'/max(max(y)));
axis off;
grid off;
camlight right;
view(-40,20);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?