11
$\begingroup$

is there any possibility to slice through a Graphics3D object? At the end I would like to have a stack of images slicing , e.g. $n$ times in $z$-direction: $((x,y,z_{0}), (x,y,z_{1}),…,(x,y,z_{n}))$

Here is an example of random spheres, which I would like to slice.

z = 100;
p = RandomReal[100, {z, 3}];
r = RandomReal[10, {z}];
obj = GraphicsComplex[p, Sphere[Range[z], r]];
t0 = AbsoluteTime[];
gr = Graphics3D[obj, Axes -> True]

I would be pleased about any suggestions.

$\endgroup$
4
  • $\begingroup$ You can use PlotRange to emulate that to a certain degree, try: Manipulate[ gr = Graphics3D[obj, Axes -> True, PlotRange -> {Automatic, Automatic, {0, z}}], {{z, 100}, 0, 100}]. For the image stack, this will be more complicated... $\endgroup$
    – Yves Klett
    Commented Sep 25, 2013 at 6:56
  • 1
    $\begingroup$ If you only want circle sections, this could be solved in an analytic fashion. Intersections on general graphics objects are not implemented yet (9.01). $\endgroup$
    – Yves Klett
    Commented Sep 25, 2013 at 7:31
  • $\begingroup$ It seems that @YvesKlett is right so maybe you can confirm that your objects are only Spheres or provide a minimal example of the data you are working with so we can help with your case. $\endgroup$
    – Kuba
    Commented Sep 25, 2013 at 8:37
  • $\begingroup$ Related: mathematica.stackexchange.com/questions/25511/… $\endgroup$
    – ybeltukov
    Commented Sep 25, 2013 at 14:36

2 Answers 2

11
$\begingroup$

You can do this by specifying a dynamic PlotRange. Here is an example using Manipulate. You will need to adapt your range for each dimension:

z = 100;
p = RandomReal[100, {z, 3}];
r = RandomReal[10, {z}];
obj = GraphicsComplex[p, Sphere[Range[z], r]];
t0 = AbsoluteTime[];
gr = Graphics3D[obj, Axes -> True]

Manipulate[
 Show[gr, PlotRange -> {{x, Automatic}, {y, Automatic}, {z, 
     Automatic}}], {x, 0, 100, 1}, {y, 0, 100, 1}, {z, 0, 100, 1}]

enter image description here

In order to generate images you will have to replace the Manipulate by a Table command and generate the images. Have a closer look at ViewPoint to specify the view on your Graphics3D object. This will allow you to generate images looking from the different directions.

Here is an example:

Manipulate[
 Show[gr, ViewPoint -> {0, -Infinity, 0}, 
  PlotRange -> {{x, Automatic}, {y, Automatic}, {z, Automatic}}], {x, 
  0, 100, 1}, {y, 0, 100, 1}, {z, 0, 100, 1}]

enter image description here

edit

To get sections you could also use PlotRange. Here is an example giving you slices of thickness 1 in y-direction:

Manipulate[
 Show[gr, ViewPoint -> {0, -Infinity, 0}, 
  PlotRange -> {{x, Automatic}, {y, y + 1}, {z, Automatic}}], {x, 0, 
  100, 1}, {y, 0, 100, 1}, {z, 0, 100, 1}]

enter image description here

$\endgroup$
0
2
$\begingroup$

If you have the analytical expressions for your surfaces (as it's the case for the spheres) there are lot of ways to do that by using any *3D[] plotting function like this:

Image3D@Table[ImageTake[
              Image@Plot3D[Sin[x y], {x, -3, 3}, {y, -3, 3}, 
                          PlotRange -> {-1, s}, ClippingStyle -> {Transparent, Green}, 
                          Boxed -> False, Axes -> False, PlotStyle -> Transparent, 
                          Mesh -> None, ViewPoint -> {0, 0, -Infinity}], 
             10 {1, -1}, 10 {1, -1}], 
         {s, -.9, .7, .1}]

Mathematica graphics

$\endgroup$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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