Guest User

Untitled

a guest
Feb 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. Manipulate[If[Abs[m] > l, m = Sign[m] l];
  2. coloredSphere[l, m, reim, ControlActive[30, pp]],
  3. {{reim, Re, "view"}, {Re -> "real", Im -> "imaginary"}},
  4. {{l, 6, "l"}, 0, 12, 1},
  5. {{m, 3, "m"}, -l, l, 1},
  6. {{pp, 40, "points"}, 3, 50, 1},
  7. Initialization :>
  8. {makeColoredSphereGraphicsComplex[points_, normals_, colors_] :=
  9. Module[{lOuter = Length[points], lInner = Length[points[[1]]]},
  10. GraphicsComplex[Flatten[N[points], 1], {EdgeForm[],
  11. GraphicsGroup[{Polygon[Flatten[#, 1] &@
  12.  
  13. Table[{i lInner + j,
  14. i lInner + j + 1, (i + 1) lInner + j +
  15. 1, (i + 1) lInner + j}, {i, 0, lOuter - 2}, {j,
  16. lInner - 1}]]}]},
  17. VertexNormals -> Flatten[N[normals], 1],
  18. VertexColors -> Flatten[N[normals], 1]]
  19. ];
  20. spherePoints[n_] := spherePoints[n] =
  21. Module[{[Psi]s = 2. Pi (Range[0, 2 n]/(2 n)), [Phi]s =
  22. 1. Pi (Range[0, n]/n)},
  23. c[Psi]s = Cos[[Psi]s]; s[Psi]s = Sin[[Psi]s];
  24. c[Phi]s = Cos[[Phi]s]; s[Phi]s = Sin[[Phi]s];
  25. [Psi]ones = Table[1., {k, 0, 2 n}];
  26. xs = Outer[Times, c[Psi]s, s[Phi]s];
  27. ys = Outer[Times, s[Psi]s, s[Phi]s];
  28. zs = Outer[Times, [Psi]ones, c[Phi]s];
  29. Transpose[{xs, ys, zs}, {3, 1, 2}]
  30. ];
  31. colors[n_, {l_, m_}, reim_] := colors[n, {l, m}, reim] =
  32. Module[{[Psi]s = 2. Pi Range[0, 2 n]/(2 n), [Phi]s =
  33. 1. Pi Range[0, n]/n, [Psi]L, [Phi]L,
  34. hueData, [CapitalDelta]h},
  35. [Psi]L = reim[Exp[I m [Psi]s]];
  36. [Phi]L = LegendreP[l, m, Cos[[Phi]s]];
  37. hueData = Outer[Times, [Psi]L, [Phi]L];
  38. [CapitalDelta]h =
  39. If[Max[hueData] == Min[hueData], 1,
  40. Max[hueData] - Min[hueData]];
  41. Map[Hue, 0.8 (hueData - Min[hueData])/[CapitalDelta]h, {2}]
  42. ];
  43. coloredSphere[l_, m_, reim_, pp_] :=
  44. Graphics3D[
  45. makeColoredSphereGraphicsComplex[spherePoints[pp],
  46. spherePoints[pp], colors[pp, {l, m}, reim]], Boxed -> False,
  47. ImageSize -> {400, 350}, SphericalRegion -> True,
  48. ViewAngle -> [Pi]/10];}]
Add Comment
Please, Sign In to add comment