Bloch sphere's in Mathematica

Just figured out how to do some pretty neat Bloch sphere's in Mathematica 6, using Sphere[], Graphics3D and ParametricPlot3D. They're interactive too.
The following code defines "bloch" which is a Graphics3D object that can be later used again, it's a bit more complicated than strickly necessary since I've added ket labels to the axes and other tweaks to make it look nice.
With[{r = 1},
xy = ParametricPlot3D[{r Cos[\[Theta]], r Sin[\[Theta]],
0}, {\[Theta], 0, 2 \[Pi]}, PlotStyle -> Dashed, Boxed -> False,
Axes -> False];
yz = ParametricPlot3D[{0, r Cos[\[Theta]],
r Sin[\[Theta]]}, {\[Theta], 0, 2 \[Pi]}, PlotStyle -> Dashed,
Boxed -> False, Axes -> False];
xz = ParametricPlot3D[{r Cos[\[Theta]], 0,
r Sin[\[Theta]]}, {\[Theta], 0, 2 \[Pi]}, PlotStyle -> Dashed,
Boxed -> False, Axes -> False];
bloch =
Show[Graphics3D[{Opacity[.6], Sphere[{0, 0, 0}, r], Opacity[1],
Black, Thick, Line[{{0, r, 0}, {0, -r, 0}}],
Line[{{0, 0, r}, {0, 0, -r}}], Line[{{r, 0, 0}, {-r, 0, 0}}],
Text[
Style["|H\[RightAngleBracket]", FontSize -> 14,
FontWeight -> Bold, FontColor -> GrayLevel[.3]], {0, 0,
1.3 r}],
Text[Style["|V\[RightAngleBracket]", FontSize -> 14,
FontWeight -> Bold, FontColor -> GrayLevel[.3]], {0,
0, -1.3 r}],
Text[Style["|D\[RightAngleBracket]", FontSize -> 14,
FontWeight -> Bold, FontColor -> GrayLevel[.3]], {1.3 r, 0,
0}], Text[
Style["|A\[RightAngleBracket]", FontSize -> 14,
FontWeight -> Bold, FontColor -> GrayLevel[.3]], {-1.3 r, 0,
0}], Text[
Style["|R\[RightAngleBracket]", FontSize -> 14,
FontWeight -> Bold, FontColor -> GrayLevel[.3]], {0, 1.3 r,
0}], Text[
Style["|L\[RightAngleBracket]", FontSize -> 14,
FontWeight -> Bold, FontColor -> GrayLevel[.3]], {0, -1.3 r,
0}]
}], xy, xz, yz, Boxed -> False]]
Then you can use it as:

Show[bloch,
Graphics3D[{Blue, Thickness[0.02],
Line[{{0, 0, 0}, {1/\[Sqrt]2, 0, 1/\[Sqrt]2}}]}]]
to get the figure on the right.
- alexei's blog
- Add new comment
- 796 reads
- reply
