# How can I plot this spirally surface?

I would like to plot a surface that looks something like this sand spiral. But I really have no idea how. Ideally I would like to be able to express this as a function in cartesian coordinates. I'm not looking for the granularity or anything, I just want a smooth spirally surface.

• Would a surface like this be acceptable as well? Jun 20 '16 at 14:18

A manual way of doing it is:

Plot3D[With[{ϕ = ArcTan[x, y], r = Sqrt[x^2 + y^2]},
0.3 Sin[2 π r + ϕ]]
, {x, -5, 5}, {y, -5, 5}
, BoxRatios -> Automatic, Mesh -> None, PlotPoints -> 25, MaxRecursion -> 4
] The reasoning behind the code is as follows: We know we want to start with some ripples radiating outwards, something like

$$\mathrm{height}(r) = h_0 \sin(r).$$

Plot3D gives us the cartesian {x,y} coordinates though, where we can evaluate our function. So we first need to express radius $r$ and for completeness and later use also our polar angle $\phi$ in terms of {x,y} which, when we investigate or look it up we find:

$$r = \sqrt{x^2+y^2}$$ $$\phi = \arctan(y/x),$$

Plot3D[With[{ϕ = ArcTan[x, y], r = Sqrt[x^2 + y^2]},
0.3 Sin[5 r]]
, {x, -5, 5}, {y, -5, 5}
, BoxRatios -> Automatic, Mesh -> None
, PlotPoints -> 25, MaxRecursion -> 4
] Almost there!

Now what we see in the reference what is still missing in the simple outward ripples is that as we go around the center the ripples shift outwards, which means that, additionally to the radius we want the effective phase in the outward rippling to also grow with the polar angle.

$$\mathrm{height}(r,\phi) = h_0 \sin(a\,r+\phi).$$

Mathematically this depicts an Archimedean Spiral.

Also we can choose a different factor for the r part in the phase, $2\pi$ is only one arbitrary value. We can get steeper or more shallow spirals with different factors.

• "Manual"? I was expecting from you solving Einstein's equation for merging black holes :) A propos 9405
– Kuba
Jun 20 '16 at 14:57
• @Kuba :D haha, i'm still an apprentice in black hole merging though ;) Jun 20 '16 at 15:06
• Nice to see you posting again! :-) Jun 20 '16 at 17:48
• This is just what I wanted! Thank you very much and thank you for the fantastically clear explanation. Jun 21 '16 at 12:57

You may want to plot z(r, fi) = sin (r + fi)

p = 20;
Plot3D[
Evaluate @ Sin @ Tr @ CoordinateTransform["Cartesian" -> "Polar", {x, y}],
{x, -p, p}, {y, -p, p},
PlotPoints -> 100, BoxRatios -> Automatic
] p = 30.;
n = 9 10^4;
pts = Catenate@Array[List, Sqrt[n] {1, 1}, {{-p, p}, {-p, p}}] +
RandomReal[.2, n];

{pts,
Sin @ Total[ CoordinateTransform["Cartesian" -> "Polar", pts], {2}]
}
] //  Sphere[#, .2] & // Graphics3D[#, Lighting -> {{"Directional",
RGBColor[1, .7, .1], {{5, 5, 4}, {5, 5, 0}}}}] & • I guess this is similar to mine, but I didn't recognize it at first. Nice texture, too. (+1) Jun 21 '16 at 4:34
• @MichaelE2 Thanks, not very efficient but I wanted to see how it looks :) Well, all are similar but each brings something, in this respect mine is the least educational :)
– Kuba
Jun 21 '16 at 6:12
• Wow! I didn't really need the sandy effect but this is awesome! Jun 21 '16 at 13:20

Here is another way that looks more like sand spirals with the tide coming in:

With[{d = 42, n = 150},
ReliefPlot[
Cos@Table[
Through[(Abs + Arg)[x + I y]], {x, -d, d, d/n}, {y, -d, d, d/n}]]] As a side note, if you want to see a physics phenomenon where such Archimedean spirals occur, you may find this link to my web page interesting.

• @ThiesHeidecke Yes, I just Through it in for fun...
– Jens
Jun 20 '16 at 16:28

Thies's solution is excellent. This was the best I could do with a logarithmic spiral:

With[{ψ = 87°},
Plot3D[Tanh[(x Sin[Tan[ψ] Log[x^2 + y^2]/2] + y Cos[Tan[ψ] Log[x^2 + y^2]/2])/10],
{x, -20, 20}, {y, -20, 20}, Axes -> None, BoundaryStyle -> None,
Boxed -> False, BoxRatios -> Automatic,
ColorFunction -> (ColorData["SandyTerrain", Clip[#3 + 1/4, {0, 3/4}]] &),
Mesh -> False, PlotPoints -> 105, PlotRange -> All]] Any wave form could be used:

ParametricPlot3D[{r Cos[t], r Sin[t], 0.2 TriangleWave[r - t/(2 Pi)]},
{r, 0, 6}, {t, 0, 2 Pi}, Mesh -> None, PlotPoints -> {121, 30}] ParametricPlot3D[{r Cos[t], r Sin[t], Sin[r - t]}, {r, 0, 60}, {t, 0,
2 Pi}, Mesh -> None, PlotPoints -> {121, 30}] Etc.

Module[{n = 15, pts},
pts = Table[{θ Cos[θ], θ Sin[θ], 0}, {θ, 0, n π, π/20}];
Graphics3D[{GrayLevel[.75], Tube[pts, π]},
ClipPlanes -> {0, 0, 1, 0},
Boxed -> False,
Lighting -> "Neutral"]] 