Here's a code that draws a set of random straight lines in 3D:
straightString[s_, x0_, y0_, z0_, u_, phi_] := {
x0 + s Sqrt[1 - u^2] Cos[phi],
y0 + s Sqrt[1 - u^2] Sin[phi],
z0 + s u
}
x0[n_] := RandomReal[{-10, 10}];
y0[n_] := RandomReal[{-10, 10}];
z0[n_] := RandomReal[{-10, 10}];
u0[n_] := RandomReal[{-1, 1}];
phi0[n_] := RandomReal[{0, 2 Pi}];
randomStrings[s_] := Table[
straightString[s, x0[n], y0[n], z0[n], u0[n], phi0[n]], {n, 1, 40}]
stringPack =
ParametricPlot3D[Evaluate@randomStrings[s], {s, -20, 20}, PlotPoints -> 2];
Show[stringPack,
PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}},
Axes -> True,
Ticks -> None,
AxesStyle -> Opacity[0.25],
AxesOrigin -> {0, 0, 0},
SphericalRegion -> True,
Method -> {"RotationControl" -> "Globe"},
ImageSize -> {700, 700}
]
Preview:
Now, I would like to modify this code to draw a pack of randomly curved and twisted "natural looking" strings. The randomization should be made while the "s" parameter is running smoothly.
Take note that I'm using a very old version of Mathematica 7.0 and I can't upgrade the machine for a newer version. So I need to use some basic functions only, nothing fancy.
stringPack = ParametricPlot3D[randomStrings[s], {s, -20, 20}, PlotPoints -> 5, MaxRecursion -> 1] /. Line -> BSplineCurve
? $\endgroup$