Skip to main content
added 121 characters in body
Source Link
Cham
  • 4.1k
  • 22
  • 39

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:

enter image description here

As you can notice on this picture, the points are all having the same size. I need them to get different random sizes.

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:

enter image description here

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:

enter image description here

As you can notice on this picture, the points are all having the same size. I need them to get different random sizes.

Source Link
Cham
  • 4.1k
  • 22
  • 39

How to add random point size to this distribution of 3d points?

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:

enter image description here