Here is a modification @belisarius asked me to post. I was playing around and made a 3D version. Putting Dynamic
inside Graphics3D
lets you rotate the fountain.
n = 100;
width = 10;
x[i_][t_] := (x0[i] + vx0[i] (t - delay[i])) UnitStep[t - delay[i]];
y[i_][t_] := (y0[i] + vy0[i] (t - delay[i])) UnitStep[t - delay[i]];
z[i_][t_] := (k \[Function]
If[k < 0,
If[Abs[x[i][t]] > width || Abs[y[i][t]] > width, (* wait until over the edge *)
delay[i] = t + RandomReal[{0, 12}], 0.01],
k])[(-#^2 + vz0@i # + z0[i]) UnitStep@# &@(t - delay[i])];
Table[x0@i = y0@i = z0@i = 0;
vx0@i = RandomReal[{-1, 1}];
vy0@i = RandomReal[{-1, 1}];
vz0@i = RandomReal[{10, 12}];
delay@i = RandomReal[{0, 12}], {i, n}];
points[s_] :=
Table[{x[i][s], y[i][s], z[i][s]}, {i, n}]~Join~
Table[{x[i][s], y[i][s], 0}, {i, n}];
{Graphics3D[
GraphicsComplex[
Dynamic@points[Clock[\[Infinity]]], {Point[Range[n],
VertexColors -> Hue /@ (Range[n]/n)], LightGray,
Point@Range[n + 1, 2 n]}],
PlotRange -> {{-width, width}, {-width, width}, {0, 40}}],
Dynamic[Clock[\[Infinity]]]}

Edit: Garden Hose
Here's a variation that uses ViewPoint
and ViewVector
to keep gravity pointing screen-down no matter how the graphics are rotated. The hose is gratuitous; but I ran into a bug with BezierCurve
, so I used BezierFunction
instead. The hose droops, too, according to the current gravity.
droplets = 200;
dist = 25;
hoseHeight = 5 - dist;
pos[t_, p0_, v0_, gravity_, delay_, droplets_] :=
Table[p0[[i]] + (gravity #^2 + v0 [[i]] #) UnitStep@# &@(t - delay[[i]]), {i, droplets}];
p0 = ConstantArray[{0., 0., hoseHeight + 3.}, droplets];
v0 = MapThread[{#1 Cos[#2], #1 Sin[#2], #3} &,
{RandomReal[{0, 1}, droplets], RandomReal[{0, 2 \[Pi]}, droplets], RandomReal[{10, 12}, droplets]}];
delay = RandomReal[{0, 13}, droplets];
points[s_] := (gravity = Normalize[(vv\[Cross]vp)\[Cross]vp];
MapIndexed[(If[Max[Abs[#]] > dist,
delay[[First[#2]]] = s + RandomReal[{0, 4}]]; #) &,
pos[s, p0, v0, gravity, delay, droplets]]);
hoseFn :=
With[{offset =
5 Normalize[{gravity[[1]], gravity[[2]] + 1.`*^-6, 0}]},
BezierFunction[{offset + {0, 0, hoseHeight - 5} + 2 dist gravity,
offset + {0, 0, hoseHeight - 5}, {0, 0, hoseHeight - 5}, {0, 0,
hoseHeight}}]];
vp = {1.8, -2.8, 0}; vv = {0., 0., 1.}; (* ViewPoint, ViewVertical *)
Graphics3D[{
GraphicsComplex[
Dynamic@points[Clock[\[Infinity]]], {Specularity[White, 10],
{Hue[0.45 + #/(4 droplets), 0.7, 1], Sphere[#, 0.25]} & /@ Range[droplets]
}],
{Thickness[0.0075], LightGray,
Line[{{0, 0, hoseHeight}, {0, 0, hoseHeight + 3.1}}], Darker@Green,
Dynamic@Line[Table[hoseFn[t], {t, 0, 1, 0.05}]]}
},
PlotRange -> dist, PlotRangePadding -> {{0, 0}, {0, 0}, {0, 0}},
ViewPoint -> Dynamic@vp, ViewVertical -> Dynamic@vv,
SphericalRegion -> True, ImageSize -> 400, Background -> Black]

In one respect it is not like a garden hose. When the graphics are rotated, the water droplets change their trajectories. In real life, you could only rotate the hose.