Construct a sphere using cuboids

3 次查看(过去 30 天)
Hello community,
I am currently faced with a problem that google and my admittedly limited programming skills couldn't solve. At the moment I am trying to create an approximation of a sphere with a given number of cuboids which have a unitary set of dimensions.
Unfortunately I couldn't find a way to let MATLAB calculate the optimal amount n, for the best surface coverage. I hope some can help !

采纳的回答

John BG
John BG 2015-12-9
编辑:Walter Roberson 2016-1-31
there are many bright people who have studied the problem you attempt to address.
As a warm-up I suggest have a look at the following:
1. http://mathworld.wolfram.com/CirclePacking.html
2. http://mathworld.wolfram.com/SquarePacking.html
3. http://www2.stetson.edu/~efriedma/packing.html
You want to approximate a sphere with cuboids, the 3D version of
4. http://www2.stetson.edu/~efriedma/squincir/
I assume without 'piercing' the surface of the sphere, otherwise for r=1, 1 with square L=sqrt(pi) has exactly same area, same would apply to any higher amount of squares always reaching zero error.
From the Stetson series of interest, since there is only mathematical proof of the 1st 2 cases, 1 square and 2 squares, I have selected those showing symmetry around x axis:
amount of squares
s1=[1 2 4 5 7 12 14 21 26 31 33 35]
instead of growing circle, normalizing Stenson's to fixed circle radius, I get:
s2=[1 5^.5/2 2^.5 10^.5/2 13^.5/2 5^.5 2.5 34^.5/2 41^.5/2 5*2^.5/2 13^.5 53^.5/2]
I just search for a short time, but did match s2 any known series, but s2 looks quite the same as page 12 of http://www.winton.phy.cam.ac.uk/DanielFletcher
showing the volume of embryo cells over amount of cells, while inside the embryo.
Obviously, you want a more general case, using cuboids instead increases variables
In MATLAB you can build a cuboid with:
xc=0;yc=0 % define where you want it centered
Dx=1;Dy=2;Dz=3 % define dimensions
dx=[-Dx/2 Dx/2];dy=[-Dy/2 Dy/2];dz=[-Dz/2 Dz/3]
[x,y,z] = meshgrid(dx,dy,dz); % generate cuboid, not centered
x = [x(:);0];y = [y(:);0];z = [z(:);0];
DT = delaunayTriangulation(x,y,z);
h1=tetramesh(DT);
camorbit(20,0)
Another easier way to build a cuboid is:
vert = [0 0 0;1 0 0;1 1 0;0 1 0;0 0 1;1 0 1;1 1 1;0 1 1];
fac = [1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;1 2 3 4;5 6 7 8];
patch('Vertices', vert, 'Faces', fac, 'FaceVertexCData', hsv(6), 'FaceColor', 'flat')
view(3)
axis([-3 3 -3 3 -3 3]);grid on
The sphere can be approximated with slices, search contourslice
x = -2:0.2:2;
y = -2:0.25:2;
z = -2:0.16:2;
[X,Y,Z] = meshgrid(x,y,z);
[Xi,Yi,Zi] = sphere;
V = X.*exp(-X.^2-Y.^2-Z.^2);
contourslice(X,Y,Z,V,Xi,Yi,Zi)
view(3)
Volume of sphere is Vol_sphere=4/3*pi*R^3
Volume of your approximation, just with cubes all same L side: for each slice Vol(i)=N(i)*L^2
where N(i) is the amount of cubes in slice I.
Vol_total=sum(Vol)
error=abs(4/3*pi-Vol_total)
If you find anything useful to start, I would appreciate you let me know about your progress.
Regards
John

更多回答(1 个)

John BG
John BG 2015-12-8
question: same cuboid? only one and only one cuboid, or different shapes of cuboids can be used to approximate a sphere?
  2 个评论
Neurosc
Neurosc 2015-12-8
编辑:Neurosc 2015-12-8
I will rephrase the question again: How do I approximate a sphere, using a finite number of cuboids that have all the same shape (fixed x,y,z values) ? And how do I make sure that the approximation I get is the optimal solution regarding the surface coverage (for a range of cuboids (e.g. n< 200)) ?
John BG
John BG 2016-1-31
same shape AND SIZE, or just same shape?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by