# How to insert variable height in this random bumps function?

I'm trying to insert a "time" variable that control the height of the random smooth bumps, but I'm yet unable to do it right, as shown with the code below:

(*SeedRandom[0]*)
(* Third coordinate in the table should be dependant on the time parameter: *)

RandomPoints = Table[{x, y, RandomReal[{-1, 1}] + (* t RandomReal[{-10, 10}] *)}, {x, -30, 30, 8}, {y, -30, 30, 8}];

RandomBumps = Interpolation[Flatten[RandomPoints, 1], Method -> "Spline"];

Manipulate[
Plot3D[
Evaluate[RandomBumps[x, y]],
{x, -30, 30}, {y, -30, 30},
PlotPoints -> 20,
MeshFunctions -> {(#3 &)},
MeshStyle -> GrayLevel[0.25],
ImageSize -> 700
],
{
t, 0, 20, 0.1,
ImageSize -> Large,
Appearance -> {"Labeled", "Closed"},
AppearanceElements -> {"InputField", "Slider"}
},
ControlPlacement -> Bottom,
FrameMargins -> None,
FrameLabel ->  {None, None,
Style["Funny Title Here!", Bold, 14, FontFamily -> "Helvetica"]}
]


Preview of what this code is doing:

I need the time parameter in the Manipulate box to randomly change the height of the bumps. Currently, it's doing nothing. What am I doing wrong here?

The smooth random bumps function is an answer from chris here: How to define a smooth function of random bumps in a plane?

• Your code doesn't work as pasted. See if you really pasted what you have in your notebook. Also, do NOT use user-defined variables with uppercase names, particularly when your name is only one letter away from a built-in function (e.g.RandomPoint). Commented Dec 9, 2020 at 23:45
• @MarcoB, I removed the $t$ culprit in the function. It should work now. About the uppercase, I know that I may encounter some conflicts, but my names are usually in French, and it's an habit to use uppercase for my functions. Sorry about that!
– Cham
Commented Dec 9, 2020 at 23:50

Update 2: If you don't need the mesh lines, the surface can be rendered very fast using BSplineSurface + Graphics3D (rather than Interpolation + Plot3D):

Manipulate[
Graphics3D[{Orange, EdgeForm[], BSplineSurface @
Table[{x, y, RandomReal[{-1, 1}] + t RandomReal[{-10, 10 }]},
{x, -30, 30, 8}, {y, -30, 30, 8}]},
Boxed -> False, ImageSize -> 400, Lighting -> "Neutral",
PlotRange -> {{-30, 30}, {-30, 30}, {-200, 200}},
BoxRatios -> 1], {t, 0, 20, Appearance -> "Open"}]


ClearAll[randomPoints, randomBumps]
randomPoints[t_] := Table[{x, y, RandomReal[{-1, 1}] + t RandomReal[{-10, 10}] },
{x, -30, 30, 8}, {y, -30, 30, 8}];

randomBumps[t_] := Interpolation[Flatten[randomPoints[t], 1], Method -> "Spline"];

Manipulate[Plot3D[Evaluate[randomBumps[t][x, y]], {x, -30, 30}, {y, -30, 30},
PlotPoints -> 20, MeshFunctions -> {(#3 &)},
MeshStyle -> GrayLevel[0.25], ImageSize -> 500], {t, 0, 20, 0.1,
ImageSize -> Large, Appearance -> {"Labeled", "Closed"},
AppearanceElements -> {"InputField", "Slider"}},
ControlPlacement -> Bottom, FrameMargins -> None,
FrameLabel -> {None, None,
Style["Funny Title Here!", Bold, 14, FontFamily -> "Helvetica"]}]


Update: Pre-computing the interpolating functions outside Manipulate should make it more responsive:

ClearAll[randomBumps]
rbumplist =  Association[# -> Interpolation[Flatten[randomPoints[#], 1],
Method -> "Spline"] & /@ Range[0, 20, 1/10]];

Manipulate[
Plot3D[Evaluate[rbumplist[t][x, y]], {x, -30, 30}, {y, -30, 30},
PlotPoints -> 20, MeshFunctions -> {(#3 &)},
MeshStyle -> GrayLevel[0.25], ImageSize -> 500,
PerformanceGoal -> "Quality"], {t, 0, 20, 1/10, ImageSize -> Large,
Appearance -> {"Labeled", "Closed"},
AppearanceElements -> {"InputField", "Slider"}},
TrackedSymbols -> {t}, ControlPlacement -> Bottom,
FrameMargins -> None,
FrameLabel -> {None, None,
Style["Funny Title Here!", Bold, 14, FontFamily -> "Helvetica"]}]


• The time variable doesn't make the shape to change continuously. Is it differentiable?
– Cham
Commented Dec 10, 2020 at 0:32
• I mean that the shape should change continuously while drawing the time slider.
– Cham
Commented Dec 10, 2020 at 0:34
• @Cham, I don't how to think about continuously and differentiable when t is discrete and you are randomly perturbing the input list for every t`. Re the responsiveness to slider to moves, there is a trade-off between the quality of rendering while you move the slider and control responsiveness.
– kglr
Commented Dec 10, 2020 at 0:50
• About the continuity and differentiability, it's because I'll need to use that fonction to define random initial and boundary conditions in a consistent way. The initial conditions need the derivative of the random field, evaluated at time 0. Maybe there's another and simpler way in doing it, but I don't see it.
– Cham
Commented Dec 10, 2020 at 0:52