Pregunta

I need to generate random lobulated contours such as the followingenter image description here

Any ideas or algorithms on how to do this ?? The software I am going to use is matlab, however I have no problem if you post solutions in other languages too...

p.s I only need to plot a random contour that resembles the above...

¿Fue útil?

Solución

How about this?

degree = 5;
numPoints = 1000;
blobWidth = 5;    

theta = 0:(2*pi)/(numPoints-1):2*pi;

coeffs = rand(degree,1);
rho = zeros(size(theta));
for i = 1:degree
    rho = rho + coeffs(i)*sin(i*theta);
end

phase = rand*2*pi;

[x,y] = pol2cart(theta+phase, rho+blobWidth);
plot(x,y)
axis equal 
set(gca,'Visible','off')

Blob

You can control the wiggliness lobulacrity by modifying degree. I think 5 gives something about as wiggly lobulacious as your example.

That was fun - hope it helps!

Otros consejos

Here is one idea.

step = 0.1;
r_min = 0.5;
r_max = 1.0;
ir = 35;
tt = linspace(0, 2*pi, ir);
t = linspace(0, 2*pi, 5*ir);

rr = r_min + (r_max - r_min)*rand(1, length(tt));
rr(end) = rr(1);
r = interp1(tt, rr, t, 'spline');
// add some noise of magnitude N
N = 0.1;
noise = -N + 2*N*rand(1, length(r));
noise(1:2:end) = 0.0;
r = r + noise;
// 
hp = polar(t, r);
set(hp, 'LineWidth', 2)

h = findall(gca,'type','line');
h(h == hp) = [];
delete(h);
t = findall(gca,'type','text');
delete(t);
delete(findall(gca, 'FaceColor', [1 1 1]))

Typical output looks like this (ir = 10, without noise)

randomly generated planar closed curve

or this (ir = 35, with and without noise)

randomly generated planar closed curve perturbed by noise

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top