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.

I was wondering if its possible to make the following type of plot in Mathematica:

I would like to take a 3D object, such as an ellipsoid, and cut out a wedge. I know this can be done using SphericalPlot3D and only plotting through an azimuthal angle phi. But here's the tricky part. Usually, whats left is a hollow shell, but I want to make it seem as if its a solid object with the inside colored according to some function. So what you would see when you cut out the wedge is a flat surface colored according to some function.

If this is not possible with Mathematica, can anyone recommend a program where this may be done?

share|improve this question
    
It can be done using RegionPlot3D‌​. –  Jens Jul 3 '13 at 4:02
    
What does the title have to do with the question? –  Rahul Narain Jul 3 '13 at 4:07
    
@RahulNarain: I agree, the title is misleading. –  Jens Jul 3 '13 at 4:08
    
I'm sorry, I don't see what is misleading about the title. I want to make an isometric object with a plot inside of a cutout of it. I think the title us summarizes the question quite well. –  Michael Ray Jul 3 '13 at 10:58
    
An "isometric" 3D drawing usually refers to a parallel projection with all three axes at 120º, as seen in old video games. Also, the title indicates nothing about cutting a wedge from a solid object and putting a plot inside the cut-out part. –  Rahul Narain Jul 4 '13 at 6:39

2 Answers 2

Here is a possible approach for the filled inside of a spherical wedge. The rest of the work consists in choosing the elliptical shape with the desired eccentricities, and possibly drawing a solid shell on top of it:

RegionPlot3D[(EuclideanDistance[{x, y, z}, {0, 0, 0}] < 1 && 
   0 < ArcTan[x, y] < Pi/4), {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
 Mesh -> False, PlotStyle -> Opacity[.5], PlotPoints -> 100]

wegde

To make the plot look isometric, just choose the ViewPoint far away, e.g., add ViewPoint -> {0, 1, 1000} to the options of RegionPlot3D.

share|improve this answer

Here's a way using SphericalPlot3D.

The segment of the surface is closed by two polygons that are formed from vertices of the boundary of the surface plot. You have to repeat the PlotStyle explicitly for the Polygons. A similar approach works for ParametricPlot3D, too, provided the wedge of the surface is cut by planes (i.e. can be represented by planar polygons).

The idea is to sow the sample theta, phi values, recover them, and extract the boundaries. These can be remapped onto the surface and become the vertices of the polygons that form the angle of the wedge. The order of the vertices of the first polygon is reversed to get the right orientation (in case FaceForm is used, for example).

sph[r_, theta_, phi_] := r {Sin[theta] Cos[phi], Sin[theta] Sin[phi], Cos[theta]};

wedge = With[{r = 1 + Sin[5 phi]/5},
 Module[{plot, pts},
  {plot, {pts}} = Reap @ SphericalPlot3D[r, {theta, 0, Pi}, {phi, 0.5, 1.8}, 
       Mesh -> None, PlotStyle -> Yellow, EvaluationMonitor :> Sow[{theta, phi}]];
  Show[
   plot,
   Graphics3D[{Yellow, Polygon[
      Apply[Function @@ {{theta, phi}, sph[r, theta, phi]},
       {Reverse @ Sort @ Cases[pts, {_, Min[Last /@ pts]}], 
        Sort @ Cases[pts, {_, Max[Last /@ pts]}]},
       {2}]
      ]}]
   ]
  ]
 ]

Mathematica graphics

To get an isometric projection of the graphics, you can play with ViewMatrix. The key is to rotate a vector of the form $(\pm 1, \pm 1, \pm 1)$ to $(0,0,1)$ and project onto the first two coordinates. Translating and scaling will depend on the particular graphics, but perhaps the example below is sufficiently generalizable.

Show[wedge, 
 ViewMatrix ->
  {TransformationMatrix[
     RescalingTransform[
       1.02 EuclideanDistance @@ Transpose[PlotRange /.
            AbsoluteOptions[wedge, PlotRange]] {{-1/2, 1/2}, {-1/2, 1/2}, {-1/2, 1/2}}] .
     RotationTransform[{{1, 1, 1}, {0, 0, 1}}] .
     TranslationTransform[-Mean /@ (PlotRange /. AbsoluteOptions[wedge, PlotRange])]
    ],
   IdentityMatrix[4]}]

Mathematica graphics

share|improve this answer

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.