14
$\begingroup$

Mathematica's Plot3D works with rectangular domains.

In other words, we write:

Plot3D[Function, {x,a,b}, {y,c,d}]

Here the domain is $[a,b]\times[c,d]$. And hence, the surface is cut in a rectangular projection.

But, what if I want my surface to be cut otherwise, say, as a circle?

To illustrate my question, I present two different images of a paraboloid:

Paraboloids.

The first one is drawn with Plot3D and the second one is obtained by revolution of a simple parabola.

RevolutionPlot3D, however, generates surfaces, which have axial symmetry only.

What should I do, if I have a non-symmetrical surface and want to cut its edges in a circle (or, if it's possible, in any other way)?

$\endgroup$
17
$\begingroup$

RegionFunction is what you are looking for.

Plot3D[4 Sin[x] + y, {x, -10, 10}, {y, -10, 10}, 
 RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 100]]

enter image description here

$\endgroup$
21
$\begingroup$

Since version 10 you can also specify the plotting domain using a geometric region. In your case, for instance, you could use:

Plot3D[3 x^2 + y^2, {x, y} ∈ Disk[]]

Mathematica graphics

This allows for interesting constructions using the full power of geometric regions:

Plot3D[x^2 + y^2,
 {x, y} ∈ RegionDifference[
    Polygon[CirclePoints[6]],
    Polygon[0.5 CirclePoints[3]]
  ]
]

Mathematica graphics

$\endgroup$
13
$\begingroup$

RevolutionPlot3D, however, generates surfaces, which have axial symmetry only.

Actually, RevolutionPlot3D[] can be used to plot in cylindrical coordinates, and not just surfaces of revolution. Not many people seem to be aware of this.

To use paw's example:

RevolutionPlot3D[With[{x = r Cos[θ], y = r Sin[θ]}, 4 Sin[x] + y],
                 {r, 0, 10}, {θ, -π, π}, MeshFunctions -> {#1 & , #2 &}]

surface cut to a circle

$\endgroup$
  • 2
    $\begingroup$ What has RevolutionPlot3D ever done to you to deserve such abuse? $\endgroup$ – Brett Champion Oct 26 '15 at 2:04
  • $\begingroup$ @Brett, hey, CylindricalPlot3D[] up and left me cold. What else was I to do, but find another? $\endgroup$ – J. M. will be back soon Oct 26 '15 at 2:35
  • $\begingroup$ I'm only talking about the conversion back to cartesian coordinates. General plotting in cylindrical coordinates is most definitely a RevolutionPlot3D feature. :-) $\endgroup$ – Brett Champion Oct 26 '15 at 4:01
  • $\begingroup$ Oh, you mean the mesh? Well, I suppose I could've stuck with the default mesh... $\endgroup$ – J. M. will be back soon Oct 26 '15 at 4:07
  • $\begingroup$ No, I mean using cylindrical coordinates to plot $f(x,y)$ instead of $f(r,t)$. $\endgroup$ – Brett Champion Oct 26 '15 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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