Identical circle packing on a rectangular surface

6 vues (au cours des 30 derniers jours)
Ege Arsan
Ege Arsan le 20 Déc 2021
Commenté : Ege Arsan le 1 Fév 2022
Dear all,
i need to pack identical circles on a certain rectangular surface (e. g. figure). I know that there isn't any general solution to this problem but i wanted to ask anyway to have a starting point.

Réponse acceptée

Image Analyst
Image Analyst le 20 Déc 2021
Modifié(e) : Image Analyst le 20 Déc 2021
See circle packing tag on the right hand side of this screen.
Here's a start:
radius = 20;
rows = 480;
columns = 640;
xc = 1 : radius*2 : columns;
yc = 1 : radius*2 : rows;
[x, y] = meshgrid(xc, yc);
% Shift every other row by a radius
x(2:2:end, :) = x(2:2:end, :) + radius;
numCircles = length(x(:))
numCircles = 192
radii = radius * ones(numCircles, 1);
viscircles([x(:), y(:)], radii, 'Color', 'r')
ans =
Group with properties: Children: [2×1 Line] Visible: on HitTest: on Show all properties
  19 commentaires
Ege Arsan
Ege Arsan le 24 Jan 2022
I tried to put yc in a while loop depending on an if statement to change the increment step between two values but couldn't figure out how to properly do it. Do you think it might work that way?
Ege Arsan
Ege Arsan le 1 Fév 2022
% Inputs
Diameter = 18;
Height = 100;
rows = 685;
columns = 300;
GapWidth = 2;
GapToTop = 5;
GapToWall =3;
Distance = 20;
r = Diameter/2;
scalingFactor = sqrt(5) / 2;
gridSpacing = r/scalingFactor+GapWidth;
% Cuboid
P = [columns/2, rows/2, Height/2];
L = [columns, rows, Height];
O = P-L/2;
plot(L,O,.8,[1 1 1]);
hold on
plot3(P(1),P(2),P(3),'*k')
alpha(.01)
%Cylinder
[X,Y,Z] = cylinder(r);
Z = Z*Height;
for i = r : scalingFactor * gridSpacing*2 : columns
for ii = r : gridSpacing*8+Distance*2 : rows
surf(X+i,Y+r,Z)
end
end
for k = r+gridSpacing: scalingFactor * gridSpacing*2 : columns
for kk= r+gridSpacing*2+Distance : gridSpacing*8+Distance*2 : rows
surf(X+k,Y+kk,Z)
end
end
if Distance>0
b = 1;
else
b = 0;
end
for l = r+(scalingFactor * gridSpacing*2)*b:scalingFactor * gridSpacing*2:columns
for ll = r+gridSpacing*4+Distance : gridSpacing*8+Distance*2 : rows
surf(X+l,Y+ll,Z)
end
end
for j = r+gridSpacing:scalingFactor * gridSpacing*2:columns-Distance
for jj = r+gridSpacing*6+Distance*2 : gridSpacing*8+Distance*2 : rows
surf(X+j,Y+jj,Z)
end
end
for n = r : scalingFactor * gridSpacing*2 : columns-Distance
for nn = r+gridSpacing*8+Distance*2: gridSpacing*8+Distance*2 : rows
surf(X+n,Y+nn,Z)
end
end
axis image
alpha(.5)
view(3)
I have managed to adjust the distance between every other two rows and plotted them as cylinders. But since i did not use viscircles for that i no longer have the number of elements. Do you have any idea how i can obtain the number of these cylinders? And do you think it is possible to obtain the center coordinates of the cylinders as an output?

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by