Re: Cropping a surface to a sphere

*To*: mathgroup at smc.vnet.net*Subject*: [mg88195] Re: Cropping a surface to a sphere*From*: "David Park" <djmpark at comcast.net>*Date*: Mon, 28 Apr 2008 04:37:35 -0400 (EDT)*References*: <fv1ff5$es6$1@smc.vnet.net>

I would like to expand on my previous reply. Many beginners at Mathematica graphics, although Szabolcs is far from a beginner!, tend to overlook the use of options in plots. Options at first seem confusing and one can usually get an impressive plot without them. But they have always been important in customizing a plot and in Version 6 they are doubly important. Many essential elements are supplied only by the options. Here is a second version of the surface cropped to a sphere using a number of options. ContourPlot3D[-x^4 y^2 + x^2 y^4 + x^4 z^2 - y^4 z^2 - x^2 z^4 + y^2 z^4 == 1, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, RegionFunction -> Function[{x, y, z, f}, x^2 + y^2 + z^2 <= 9], ContourStyle -> {FaceForm[ColorData["Legacy"]["DarkSeaGreen"], GrayLevel[.7]]}, PlotPoints -> 25, Mesh -> False, (* Use white lights instead of colored lights *) Lighting -> "Neutral", Axes -> False, Boxed -> False, (* The following options provide a smooth rotation with the mouse *) SphericalRegion -> True, RotationAction -> Clip, (* The following option causes the plot to fill the viewing area *) PlotRegion -> {{-.3, 1.3}, {-.3, 1.3}}, Background -> ColorData["Legacy"]["LightBeige"], ImageSize -> 500] It's not clear that we need the bounding box or the axes. We might just say it is the surface out to a radius of 3. The colored lights add nothing to the plot. They only introduce confusion so we use Neutral lighting. We then use the ContourStyle option to give different colors to the inside and outside of the surface. If you don't like the image jumping around when you use the mouse to rotate, you can use the SphericalRegion and RotationAction options. The PlotRegion option gives us an initial view such that the object fills the viewing area. You can also use the mouse zoom function to control this. Then we use a Background to tone down the plot and ImageSize to control the initial size. There are many other options that might be used. I hope you will agree that this is a much better presentation of the surface than my previous reply without all the options. -- David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ "Szabolcs Horv=E1t" <szhorvat at gmail.com> wrote in message news:fv1ff5$es6$1 at smc.vnet.net... > > Is there a simple way to crop a surface to a sphere? > > For example, consider the surface > > ContourPlot3D[ > -x^4*y^2 + x^2*y^4 + x^4*z^2 - y^4*z^2 - > x^2*z^4 + y^2*z^4 == 1, > {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, > Mesh -> False] > > It is cropped to a cube (the bounding box) by default. I would like to > crop it to a sphere of radius 3 (or some other region). > > Is there an easy way to do this? I guess that if there really isn't a > better way, I could write a polygon cropping function, convert the > graphic to Normal[] form, and crop/remove each polygon one by one, but I > was hoping for a simpler solution ... (built-in function or existing > package). >