Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*///////////////////////////////////////////////////////////////////*)
- (* Prime Nebula 3D - iomikron.tumblr.com *)
- (*///////////////////////////////////////////////////////////////////*)
- (* this is a list of primes *)
- primes = Table[Prime[i], {i, 5, 3000}];
- (* this is the initial point*)
- p3 = {0, 0, 0};
- (* list for the points'coordinates storage *)
- mList = {};
- (* list for the points' colours *)
- cList = {};
- (* lis for the main transition steps *)
- possibleSteps = {{0, 0, 1}, {0, 0, -1}, {1, 0, 0}, {-1, 0, 0}, {0, 1,
- 0}, {0, -1, 0}};
- length = Length[primes];
- (* main loop *)
- Do[
- pos = 0;
- counter = primes[[iterator]];
- y = Mod[counter, 7];
- (* add the transition step to the current position *)
- p3 = p3 + possibleSteps[[y]];
- (* check if the current position is overwritten *)
- If[Length[Union[mList, {p3}]] == Length[mList],
- (* TRUE - store the point in mList *)
- pos =
- Flatten[Position[mList, p3]][[1]];
- (* TRUE - store the colour of the point in cList*)
- cList =
- ReplacePart[cList,
- pos -> 0.01 + cList[[pos]]
- ],
- (* FALSE - set a new element in clist *)
- cList = Append[cList, 0];
- (* FALSE - set a the new point in the mList *)
- mList = Append[mList, p3];
- ],
- {iterator, 1, length}
- ];
- (* setup the list of points with size and colour *)
- max = Max[cList];
- min = Min[cList];
- slope = 0.017/(max - min);
- PointList3d =
- Table[{PointSize[slope*(cList[[i]] - max) + 0.018],
- Blend[{Darker[Red, .7], Lighter[Yellow, .5], Lighter[Yellow, .6],
- Lighter[Yellow, .7], Lighter[Yellow, .8], White}, cList[[i]] ],
- Point[mList[[i]] ]},
- {i, Length[mList]}];
- (* Plot the set of points *)
- Graphics3D[PointList3d,
- AspectRatio -> 1, Background -> Black, Axes -> False,
- AxesOrigin -> {0, 0, 0}, AxesStyle -> GrayLevel[0.3],
- Boxed -> False, RotationAction -> "Clip", SphericalRegion -> True,
- ViewVector -> {570 Cos[0], 570 Sin[0], 20}, ImageSize -> {500, 500}]
Advertisement
Add Comment
Please, Sign In to add comment