The code below creates a random distribution of points in 3D. Currently, the points have a random size, and the size is the same for all points. I need the points to get individually a random size, not the same for all points. How can I modify that code to do that? Please, the solution should work with old versions of Mathematica (I'm still using version 7.0 since my computer is very old). The colors could be random too, but I want to concentrate on the size first.
points3D[p_, q_, r_] := Module[{dat = RandomReal[{-1, 1}, {p, 3}]},
Do[AppendTo[dat, r RandomReal[{-1, 1}, 3] + RandomChoice[dat]], {i, q}]; dat
]
graph3D[p_, q_, r_] := Graphics3D[{RGBColor[{0.5, 0.4, 1.0, 0.4}], PointSize[RandomReal[{0.004, 0.01}]], Point[points3D[p, q, r]]}]
view[p_, q_, r_] := Show[{graph3D[p, q, r]},
PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}},
Boxed -> True,
Background -> Black,
ImageSize -> {700, 700},
SphericalRegion -> True,
Method -> {"RotationControl" -> "Globe"}
]
view[200, 5000, 0.1]
Preview of what this code is doing:
As you can notice on this picture, the points are all having the same size. I need them to get different random sizes.
Point
must have its ownPointSize
. Change definition ofgraph3D
tograph3D[p_, q_, r_] := Graphics3D[{RGBColor[{0.5, 0.4, 1.0, 0.4}], {PointSize[RandomReal[{0.004, 0.01}]], Point[#]} & /@ points3D[p, q, r]}]
$\endgroup$Manipulate[view[p, q, r], {{p, 200}, 100, 300, 5, Appearance -> "Labeled"}, {{q, 5000}, 2000, 8000, 1000, Appearance -> "Labeled"}, {{r, 0.1}, 0.05, 0.2, 0.05, Appearance -> "Labeled"}, TrackedSymbols :> All, SynchronousUpdating -> False]
$\endgroup${PointSize[RandomReal[{0.004, 0.01}]], Point[#]} & /@ points3D[p, q, r]
is the same asMap[{PointSize[RandomReal[{0.004,0.01}]], Point[#]}&, points3D[p,q,r]]
$\endgroup$AppendTo
is inefficient, useTable
andJoin
, i.e.,points3D[p_, q_, r_] := Module[{dat = RandomReal[{-1, 1}, {p, 3}]}, Join[dat, Table[r RandomReal[{-1, 1}, 3] + RandomChoice[dat], {i, q}]]]
$\endgroup$