TransWikia.com

Fill in the hollow Spheres - generate solid spheres

Mathematica Asked by Charis Sideris on December 26, 2020

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

One Answer

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

Answered by cvgmt on December 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP