Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

For my lecture notes in theoretical physics (namely quantum mechanics) I'm trying to visualize the spherical harmonics. I got Mathematica to plot them an this is what I did:

SphericalPlot3D[(Sqrt[3/(4*Pi)]*Sin[theta]*Cos[phi])^2,
  {theta, 0, Pi}, {phi, 0, 2*Pi}, PlotRange -> All, PlotPoints -> 50]

That gives me this picture:

Spherical Harmonic

Now I want to plot it using pst-3dplot (or pst-solides3d) but I don't know how since there is no option like SphericalPlot3D. I tried using \parametricplotThreeD but this doesn't output anything useful. Here is my MWE for this

\documentclass{minimal}
\usepackage{pst-3dplot}
\begin{document}

\centering
\psset{algebraic=true}
\begin{pspicture}(-2,-3.5)(4,0)
  \parametricplotThreeD[SphericalCoor=true](0,\psPi)(0,\psPiTwo)%
    {t | u | (sqrt(3/(4*\psPi))*sin(t)*cos(u))^2}
\end{pspicture}

\end{document}

This is the output

Useless image

Thanks in advance.

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

The function \parametricplotThreeD takes the x,y,z-coordinates of the surface as arguments, whereas t and u are polar and azimuthal angles. The following code gives what you are looking for:

\documentclass{minimal}
\usepackage{pst-3dplot}
\begin{document}

\centering
\psset{algebraic=true}
\begin{pspicture}(-2,-3.5)(4,0)
  \parametricplotThreeD[SphericalCoor=true](0,\psPi)(0,\psPiTwo)%
    { cos(u)^3*sin(t)^3 | sin(u)*sin(t)^3*cos(u)^2 | cos(t)*sin(t)^2*cos(u)^2 }
\end{pspicture}

\end{document}

Another option for nice 3D plots is Asymptote, see the gallery which also has a plot of a spherical harmonic.

share|improve this answer
add comment

Thanks to Alex' answer I was able to redo the plot using pst-solides3d

\documentclass[pstricks,border=3pt]{standalone}
\usepackage{pst-plot}
\usepackage{pst-solides3d}
\begin{document}

\begin{pspicture}(-1,-1)(1,1)
  \defFunction[algebraic]{harmonic}(u,v)
  {sin(u)*cos(v)*(sqrt(3/(4*\psPi))*sin(u)*cos(v))^2}
  {sin(u)*sin(v)*(sqrt(3/(4*\psPi))*sin(u)*cos(v))^2}
  {cos(u)*(sqrt(3/(4*\psPi))*sin(u)*cos(v))^2}
  \psSolid[object=surfaceparametree,
    base=0 pi 0 pi 2 mul,
    function=harmonic,
    linewidth=0.5\pslinewidth,
    ngrid=25 40
  ]
\end{pspicture}

\end{document}

Spherical harmonic

share|improve this answer
    
Why didn't use \documentclass[pstricks,border=3pt]{standalone}? –  I am who I say I am Feb 17 '13 at 20:00
    
I didn't know about that. I will adjust my post. Thank you. –  Henri Menke Feb 17 '13 at 20:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.