Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCube[cubes_] := Module[{chosen, chosendir},
- chosen = RandomChoice[cubes];
- chosendir =
- RandomChoice[{-1,
- 1}] RandomChoice[{{0, 0, 1}, {0, 1, 0}, {1, 0, 0}}];
- Union[Join[cubes, {chosen + chosendir}]]
- ];
- cs = "DarkRainbow";
- face1[p_, \[Theta]_] :=
- Map[(p + RotationMatrix[\[Theta], {1, 0, 0}].#) &, {{0, 0, 0}, {1,
- 0, 0}, {1, 1, 0}, {0, 1, 0}}];
- face2[p_, \[Theta]_] :=
- Map[(p + RotationMatrix[\[Theta], {0, 1, 0}].#) &, {{0, 0, 0}, {0,
- 0, 1}, {0, 1, 1}, {0, 1, 0}}];
- face3[p_, \[Theta]_] :=
- Map[(p + RotationMatrix[\[Theta], {0, 0, 1}].#) &, {{0, 0, 0}, {1,
- 0, 0}, {1, 0, 1}, {0, 0, 1}}];
- cuboid[cube_, \[Theta]_] :=
- Module[{f1 = face1[cube, \[Theta]], f2 = face2[cube, \[Theta]],
- f3 = face3[cube, \[Theta]]},
- {
- {Glow@ColorData[cs][1/3], Polygon[{f1}]},
- {Glow@ColorData[cs][2/3], Polygon[{f2}]},
- {Glow@ColorData[cs][3/3], Polygon[{f3}]}
- }
- ];
- frame[\[Theta]_] :=
- Graphics3D[
- {Black, EdgeForm[],
- Table[
- cuboid[cube, \[Theta]]
- , {cube, cubes}]
- }
- , Lighting -> "Neutral", ViewPoint -> -1000 {1.2, 1.2, 1},
- Boxed -> False, PlotRange -> All, ImageSize -> {300, 300}];
- cubes = Nest[AddCube, {{0, 0, 0}}, 200];
- Manipulate[frame[t],{t,0,2 Pi}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement