Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
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... –  Yves Klett Sep 25 '13 at 6:56
1  
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). –  Yves Klett Sep 25 '13 at 7:31
    
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. –  Kuba Sep 25 '13 at 8:37
    

2 Answers 2

up vote 6 down vote accepted

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

share|improve this answer
    
Yes, you are right. I forgot to add the last bit of code I created :) –  g3kk0 Sep 25 '13 at 7:07

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

share|improve this answer
1  
yuck... why green? Image search returns this :-) –  Yves Klett Sep 25 '13 at 14:43
    
@YvesKlett Green, as most things in the history of mathematics is just because I like it en.wikipedia.org/wiki/History_of_mathematical_notation :) –  belisarius Sep 25 '13 at 15:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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