2
$\begingroup$

I'd like to generate microstructures of composite materials and I use an algorithm to find the centers of the spheres knowing also the radius.

My problem is that I only want solid spheres in order to export in a next step this file in .obj type and then in .vtk type.

Does anyone know how to make the spheres solid in the whole sphere's volume?

The plot code I use is the next one:

Graphics3D[{Sphere[X, r]}, PlotRange -> {{0, L}, {0, L}, {0, L}}, Lighting -> Automatic]

where X corresponds to the center of the spheres.

Here is an example of my microstructure:

enter image description here

$\endgroup$
4
  • 3
    $\begingroup$ Ball[X,r] is a solid. $\endgroup$
    – cvgmt
    Dec 14 '20 at 23:37
  • $\begingroup$ This Compute Lattice Packing Densities:New in Wolfram Language 12 seems relevant. $\endgroup$
    – Tim Laska
    Dec 14 '20 at 23:42
  • $\begingroup$ @cvgmt Ball gives the same result $\endgroup$ Dec 14 '20 at 23:43
  • $\begingroup$ @TimLaska Thanks both of you for the quick response, but I forgot to say that I have downloaded the 11.3 version and as I tried the RegionPlot3D command I had the same problem because the spheres looked solid but when I exported in obj type, again looked hollow inside $\endgroup$ Dec 15 '20 at 0:13
2
$\begingroup$

Thanks for @Tim Laska Provide the advice.

centers = RandomReal[{-2, 2}, {10, 3}];
unitball[c_, x_] := EuclideanDistance[c, x] <= 1;
regs = Show[
  RegionPlot3D[
     unitball[#, {x, y, z}], {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
     Mesh -> False, Boxed -> False, Axes -> False] & /@ centers]
Export["test.obj",regs]

Or use Ball[] and RegionMember

centers = RandomReal[{-2, 2}, {10, 3}];
Table[RegionPlot3D[
    RegionMember[Ball[center], {x, y, z}], {x, -1, 1}, {y, -1, 
     1}, {z, -1, 1}, Mesh -> False, Boxed -> False, Axes -> False], {center, centers}] // Show;
Export["test.obj", %]

enter image description here

Another way maybe work.

centers = RandomReal[{-2, 2}, {4, 3}];
cuboid = Cuboid[{-1, -1, -1}, {1, 1, 1}];
balls = DiscretizeRegion /@ Ball /@ centers;
newballs = RegionIntersection[#, cuboid] & /@ balls // Quiet;
regs = Show[DeleteCases[newballs, _EmptyRegion]]

enter image description here

$\endgroup$
4
  • $\begingroup$ BoundaryStyle -> None $\endgroup$
    – cvgmt
    Dec 16 '20 at 23:55
  • $\begingroup$ Thanks a lot for your help! $\endgroup$ Dec 18 '20 at 19:35
  • $\begingroup$ @CharisSideris Do you have other question about this answer? $\endgroup$
    – cvgmt
    Dec 19 '20 at 2:04
  • $\begingroup$ No thanks! I solved the problem I had, with your help $\endgroup$ Dec 19 '20 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.