Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

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.

share|improve this question
    
Would a surface like this be acceptable as well? – J. M. 16 hours ago

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.

share|improve this answer
4  
"Manual"? I was expecting from you solving Einstein's equation for merging black holes :) A propos 9405 – Kuba 15 hours ago
    
@Kuba :D haha, i'm still an apprentice in black hole merging though ;) – Thies Heidecke 15 hours ago
1  
Nice to see you posting again! :-) – Mr.Wizard 12 hours ago

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

share|improve this answer
    
I guess this is similar to mine, but I didn't recognize it at first. Nice texture, too. (+1) – Michael E2 2 hours ago
    
@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 35 mins ago

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.

share|improve this answer
    
+1 Nice use of Through! – Thies Heidecke 14 hours ago
3  
@ThiesHeidecke Yes, I just Through it in for fun... – Jens 14 hours ago
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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

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.