Advertisement
Matthen

Sierpinski 5 cell

Jun 4th, 2013
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. as = N[{{1/Sqrt[10], 1/Sqrt[6], 1/Sqrt[3], 1}, {1/Sqrt[10], 1/Sqrt[6],
  2. 1/Sqrt[3], -1}, {1/Sqrt[10], 1/Sqrt[6], -2/Sqrt[3], 0}, {1/
  3. Sqrt[10], -(Sqrt[3]/Sqrt[2]), 0, 0}, {-2 Sqrt[2]/Sqrt[5], 0, 0,
  4. 0}}];
  5. simplex[c_, s_] := s (Map[# + c &, as]);
  6. rot[ps_, t_] := (RotationMatrix[
  7. t, {{0, 0, 1, 0}, {0, 1, 0, 0}}].RotationMatrix[
  8. 2 t, {{1, 0, 0, 0}, {0, 0, 0, 1}}].#) & /@ ps;
  9. proj[ps_, t_] := Most[#]/(3 - Last[#]) & /@ rot[ps, t];
  10. Plot4D[ptlist_, t_, opts : OptionsPattern[Graphics3D]] :=
  11. Graphics3D[
  12. Table[
  13. GraphicsComplex[proj[ps, t],
  14. {
  15. {RGBColor[0.8, 0.9, 0.95], Tube[
  16. Tuples[Range[Length[ps]], 2]
  17. , 0.005],
  18. White,
  19. Polygon[
  20. Tuples[Range[Length[ps]], 3]
  21. ]
  22. }
  23. }
  24. ]
  25. , {ps, ptlist}],
  26. Evaluate[opts]
  27. ];
  28. Clear[sier];
  29. sier[0] = {simplex[{0, 0, 0, 0}, 1]};
  30. sier[n_] :=
  31. Flatten[Table[Table[Map[(a + #)/2 &, s], {a, s}], {s, sier[n - 1]}],
  32. 1];
  33. niter=2
  34. Manipulate[
  35. Plot4D[
  36. sier[niter]
  37. , t, PlotRange -> 0.5, Boxed -> False,
  38. Lighting -> {{"Directional",
  39. RGBColor[1, .7, .1], {{5, 5, 4}, {5, 5, 0}}}}],
  40. {t, 0, 2 Pi}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement