Problem beim Schneiden von Würfeln

Sep 26 2020
Show[Graphics3D[{Cuboid[]}],
ContourPlot3D[{x==1/3,y==1/4,z==1/5},{x,-0.2,1.2},{y,-0.2,1.2},{z,-0.2,1.2}]]

Drei Ebenen teilen den Einheitswürfel in 8 kleine Würfel. Was ist der einfachste Weg, um diese 8 kleinen Quader zu erhalten? Ich habe versucht, die regionale boolesche Operation zu
RegionIntersection[Cuboid[], ImplicitRegion[x < 1/3 && y < 1/4 && z < 1/5, {x, y, z}]]geben

BooleanRegion [# 1 && # 2 &, {Cuboid [{0,0,0}], ImplicitRegion [x <1/3 && y <1/4 && z <1/5, {x, y, z}]}]

aber ich möchte

Quader [{0, 0, 0}, {1/3, 1/4, 1/5}]

Die erwartete endgültige Ausgabe ist

{Quader [{1 / 3,1 / 4,1 / 5}, {1,1,1}], Quader [{1 / 3,1 / 4,0}, {1,1,1 / 5}] , Quader [{1 / 3,0,1 / 5}, {1,1 / 4,1}], Quader [{1 / 3,0,0}, {1,1 / 4,1 / 5}] , Quader [{0,1 / 4,1 / 5}, {1 / 3,1,1}], Quader [{0,1 / 4,0}, {1 / 3,1,1 / 5}] , Quader [{0,0,1 / 5}, {1 / 3,1 / 4,1}], Quader [{0,0,0}, {1 / 3,1 / 4,1 / 5}] }}

Show[Graphics3D[{Cuboid[]}],
ContourPlot3D[{x==1/3,y==1/4,z==1/5,x==3/4,y==5/6,z==6/7},
{x,-0.2,1.2},{y,-0.2,1.2},{z,-0.2,1.2}]]

Wenn es auf sechs Flugzeuge erweitert werden kann, ist es besser.

Antworten

5 kglr Sep 26 2020 at 13:23
xmesh = {0, 1/3, 2/3, 1};
ymesh = {0, 1/4, 2/4, 3/4, 1};
zmesh = {0, 1/5, 3/5, 4/5, 1};

cuboids =  Cuboid@@@(Transpose /@ Tuples[Partition[#, 2, 1]& /@ {xmesh, ymesh, zmesh}]);

Graphics3D[{Opacity[.3, RandomColor[]], #} & /@ cuboids, Boxed -> False]

4 DavidG.Stork Sep 26 2020 at 12:04

Dies kann mit viel eleganter und knapper gemacht werden Outer, aber es funktioniert:

xplanes = {1/3, 2/3};
yplanes = {1/4, 2/4, 3/4};
zplanes = {1/5, 3/5, 4/5};
ends = {0, 1};

myPlanes = Union[ends, #] & /@ {xplanes, yplanes, zplanes};

theCuboidlets=Flatten[Table[
  Cuboid[{myPlanes[[1, i]], 
          myPlanes[[2, j]], 
          myPlanes[[3, k]]}, 
        {myPlanes[[1, i + 1]], 
         myPlanes[[2, j + 1]], 
         myPlanes[[3, k + 1]]}],
  {i, Length[myPlanes[[1]]] - 1},
  {j, Length[myPlanes[[2]]] - 1},
  {k, Length[myPlanes[[3]]] - 1}]];

Graphics3D[theCuboidlets]