Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
RegionPlot3D[ Sqrt[x^2 + y^2] <= z && x^2 + y^2 + z^2 <= 2, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, Mesh -> None, AxesLabel -> {x, y, z}, PlotRange -> All, PlotPoints -> 120, PlotStyle -> Directive[Yellow, Specularity[White, 20], Opacity[0.8]]]

It gives me the result (Hemisphere on top on a cone ) I want but because I have never taken high level of math courses I do not have any explanation why I use Sqrt[x^2 + y^2] <= z as the equation for the cone. I will appreciate your kindness


share|improve this question
Sqrt[x^2 + y^2] <= c where c is a constant defines a circle. So you can picture Sqrt[x^2 + y^2] <= z as being a small circle when z is small and a larger circle when z is large. Hence, over the range of z values, you get the cone. – bill s Sep 22 '13 at 3:20
up vote 4 down vote accepted

I don't know how best to explain it, but I'll try.

Sqrt[x^2 + y^2] gives you a distance to (x, y) from the origin (0, 0) because it is the solution to the Pythagorean Theorem. Viewed as a density plot it looks like this:

DensityPlot[Sqrt[x^2 + y^2], {x, -2, 2}, {y, -2, 2}]

enter image description here

Dark values represent small distance while light values represent large distance.

If you plot this in three dimensions with the distance as height (z axis) you get a cone with square edges because you are plotting over a square region:

ParametricPlot3D[{x, y, Sqrt[x^2 + y^2]}, {x, -2, 2}, {y, -2, 2}, BoxRatios -> 1]

enter image description here

To get a "normal" cone you need to cut the top off in a level line as viewed from the x and y axes. To do this you could clip any value with a distance (z-value) greater than the radius of the circle that should make up the base of your cone:

ParametricPlot3D[{x, y, Sqrt[x^2 + y^2]}, {x, -2, 2}, {y, -2, 2}, BoxRatios -> 1, 
  RegionFunction -> (#3 < 2 &)]

enter image description here

Another way to express that is to limit the z-value to 2 by using Min[2, z]:

ParametricPlot3D[{x, y, Min[2, Sqrt[x^2 + y^2]]}, {x, -2, 2}, {y, -2, 2}, BoxRatios -> 1]

enter image description here

Here the corners are not removed but instead flattened, and the circular base is again revealed.

share|improve this answer
Thank you so much – Maggie Sep 22 '13 at 4:45
@Maggie You're welcome. If you are satisfied with an answer you can Accept it by clicking the check-mark to the left of it. – Mr.Wizard Sep 23 '13 at 13:20

Your Answer


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.