# Plotting a section of an hemisphere

I'm writing a little package in Mathematica for geology where a particular stone may be approximated as an hemisphere. Anyway this is a rough estimation because a real hemisphere has its height as loong as its radius. Instead, a reservoir stone (for an hydrocarbon) has often a form of a section of an hemisphere, its height is lower than the radius. For example, I can have an hemisphere with radius long 5 km and height of only 3 km and I can plot it like that:

semisfera[x_, y_, raggio_] := Sqrt[raggio^2 - (x - raggio)^2 - (y - raggio)^2];
plotsemisfera = Plot3D[semisfera[x, y, raggioSfera], {x, 0, 2  raggioSfera}, {y, 0, 2  raggioSfera}, PlotRange -> {0, 3}, AxesLabel -> {"lunghezza km" , "larghezza km","profondità km"}, PlotLabel ->  Style[Framed["Referenced Theorical Hemisphere"], 22, Black]]


and I get the following graphic: you'll agree with me that is a section of ah hemisphere without the top part, won't you?

Sometimes it may happen that the height is << radius. In my case, my geology student worked on a stone with radius of 5km and an height of only 0.2 km. If I try to plot this as I've done before, I get a very awful graphic, here: So, I'd just like to know if there is a way to plot a more precise graphic, without all that irregular part at the base of the hemisphere.

The centre of the "hemisphere" should be in = <0,0>

Maybe it could be something like that: http://uploadpie.com/eAVvq

but I really don't understand why for low values of the height the base of the hemisphere is so jagged!

How can I plot that? Thank you

• SphericalPlot3D[1, {\[Theta], 0, Pi/5}, {\[Phi], 0, 2 Pi}, AspectRatio -> Automatic] – Kuba Apr 8 '14 at 11:30
• Need more info. Do you want a 3D plot or a 3D graphic? Do you want it defined in terms of radius and height? Is center at the origin OK, or do you want to position the "stone" arbitrarily? – m_goldberg Apr 8 '14 at 11:54
• Ehm, it's a bit difficult to understand. I've tried what you've written but what I meant was a section of a hemisphere without the top...it should look like a conic section, not of a cone but of an hemisphere. The underneath part, not the top one. is it a bir clearer? :S – Lory Lory Apr 8 '14 at 13:26
• The stone can be put in the centre <0,0> anyway it's not very important. And yes, I'd need a 3D graphic depending on radius and height. – Lory Lory Apr 8 '14 at 13:36
• @LoryLory Here are some ideas to get this question reopened so it can be answered: Share the code you used for that plot, put the image in the question, share a photo of the stone if you have it and look over your description in the question and see again if you can improve, perhaps by clarifying some of the misconceptions in the comments. – C. E. Apr 8 '14 at 14:20

### Edit

I now have a better understanding of what you are looking for.

To get plot centered at the origin defined in terms of the radius and height, then you can use SphericalPlot3D as Kuba suggested. It would go like this.

theta[r_, h_] /; 0 < h < r := π/2. - ArcTan[Sqrt[r^2 - h^2], h]
With[{r = 5, h = 3, zScale = .3},
SphericalPlot3D[r, {θ, theta[r, h], π/2}, {ϕ, 0, 2 π}, BoxRatios -> {1, 1, zScale}]] Note the use of a parameter to scale z-axis. It is set to h/(2 r) in the above plot. This gives true proportions.

In the extreme of r = 5 and h = .2, zScale will need to be adjusted to give a reasonable looking plot, which is going to look very much like a cylinder.

With[{r = 5, h = .2, zScale = .25},
SphericalPlot3D[r, {θ, theta[r, h], π/2.}, {ϕ, 0, 2 π}, BoxRatios -> {1, 1, zScale}]] • The stone can be put in the centre <0,0> anyway it's not very important. And yes, I'd need a 3D graphic depending on radius and height. – Lory Lory Apr 8 '14 at 13:36
• Thank you mate! Forgive for my brief question today but I was very busy in two projects...I've been too short. Sorry! Thank you very much! – Lory Lory Apr 8 '14 at 19:49
• ps: forgive me if I can't mark your answer as useful but I havent't 15 points of reputation yet – Lory Lory Apr 9 '14 at 7:48

The ragged edges were caused by the fact that the parametrization of the surface in terms of height over the equatorial plane is singular at the equator, as you can also see in the increased distance between mesh lines on the plotted surface. So the main part of the solution is to choose a better parametrization, and the most common one is of course some variation of spherical coordinates.

Here is a completely different approach which also uses an angle to parametrize the surface, but should yield a more reusable and render-friendly object that can be displayed in Graphics3D.

It uses the fact that Tube can be provided not just with a list of points on which it is centered, but also accepts a second argument that contains a list of diameters. I use this to draw the shell. Tube is therefore a quick and simple way to define rotationally symmetric shapes without using one of the Plot3D family commands.

Clear[pebble];
pebble[h_, n_: 40] := {
CapForm["Butt"],
Apply[Tube,
Transpose[
Table[
{{0, 0, Sin[θ]}, Cos[θ]},
{θ, 0, ArcSin[h], Pi/(2 n)}]]]
}

Graphics3D[{Lighter[Brown], pebble[.7]}, Lighting -> "Neutral",
Boxed -> False] Graphics3D[{Lighter[Brown], Table[
Translate[
Rotate[Scale[ pebble[.1 i], RandomReal[{.1, 1.5}]],
i Pi/10, {0, 1, 0}], {2 i, i, 0}], {i, 1, 10}]},
Lighting -> "Neutral", Boxed -> False] The function pebble has only one required argument: the height from the equator, assumed to be between 0 and 1. So it's basically the aspect ratio, and in the second plot I show how to adjust the overall size using Scale in Graphics3D. The second optional argument to pebble is the resolution with which the surface is drawn, given in terms of the number of latitude divisions.

• Thank you! This is very interesting...I'm afraid one will never know enough about plotting in mathematica. I'll try your suggest and to put it in my project. Thank you a lot! ps: forgive me if I can't mark your answer as useful but I havent't 15 points of reputation yet – Lory Lory Apr 9 '14 at 7:47