I was trying to generate a random shape in MATLAB and i found a code here exactly i want. The code is following:
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')
I found this very helpful. But i need multiple shapes adjacent to each other with random radii. Need an urgent help Please.
Aucun commentaire:
Enregistrer un commentaire