/ concept-collection / turing-surface
Sign in
concept-collection / turing-surface
19 lines · 674 BCodeBlameHistory
0ae15cfSeed runs from smooth random fields, and add the blob geometryDan Fortunato 1% A random blob: the sphere, radius-modulated by a smooth random function
2% on the sphere — surfacefun's blob, built on chebfun's randnfunsphere
3% (tools/randnfunsphere.m).
4%
5% `seed` picks the draw; the same seed always gives the same blob. `scale`
6% is the random function's wavelength, so smaller means finer lobes.
8function [gx, gy, gz] = shape(theta, phi, amp, scale, seed)
9 rng(seed);
10 f = randnfunsphere(scale, theta, phi);
11 % blob.m's normalization: shift nonnegative, rescale to [-1, 1].
12 f = f + abs(min(f));
13 f = 2*(f/max(f)) - 1;
14 r = 1 + amp*f;
15 st = sin(theta);
16 gx = r .* (st .* cos(phi));
17 gy = r .* (st .* sin(phi));
18 gz = r .* cos(theta);
19end
moveopenescclose