15
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Would a surface like this be acceptable as well? $\endgroup$ – J. M. is away Jun 20 '16 at 14:18
31
$\begingroup$

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
]

Sand Spiral

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),$$

which leads us to

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
]

Radial ripples

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.

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

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
]

enter image description here

p = 30.;
n = 9 10^4;
pts = Catenate@Array[List, Sqrt[n] {1, 1}, {{-p, p}, {-p, p}}] + 
   RandomReal[.2, n];

MapThread[ Append, 
  {pts, 
   Sin @ Total[ CoordinateTransform["Cartesian" -> "Polar", pts], {2}]
  }
] //  Sphere[#, .2] & // Graphics3D[#, Lighting -> {{"Directional", 
  RGBColor[1, .7, .1], {{5, 5, 4}, {5, 5, 0}}}}] &

enter image description here

$\endgroup$
  • $\begingroup$ I guess this is similar to mine, but I didn't recognize it at first. Nice texture, too. (+1) $\endgroup$ – Michael E2 Jun 21 '16 at 4:34
  • $\begingroup$ @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 :) $\endgroup$ – Kuba Jun 21 '16 at 6:12
  • $\begingroup$ Wow! I didn't really need the sandy effect but this is awesome! $\endgroup$ – user41147 Jun 21 '16 at 13:20
5
$\begingroup$

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.

$\endgroup$
  • 3
    $\begingroup$ @ThiesHeidecke Yes, I just Through it in for fun... $\endgroup$ – Jens Jun 20 '16 at 16:28
4
$\begingroup$

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]]

I hope it looks somewhat sandy at least.

$\endgroup$
4
$\begingroup$

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}]

Mathematica graphics

ParametricPlot3D[{r Cos[t], r Sin[t], Sin[r - t]}, {r, 0, 60}, {t, 0, 
  2 Pi}, Mesh -> None, PlotPoints -> {121, 30}]

Mathematica graphics

Etc.

$\endgroup$
3
$\begingroup$
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"]]

spiral

$\endgroup$

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.