\listfiles
\documentclass[12pt,a4paper]{article}
\usepackage{pst-3dplot, pst-slpe}
\usepackage{pstricks-add}
\usepackage{pst-pdf}
%% Hack for \psbrace in combination with older pstricks-add versions:
\makeatletter
\pst@def{UserCoor}< \pst@number\psyunit div exch \pst@number\psxunit div exch >
\pst@def{ScreenCoor}< \pst@number\psyunit mul exch \pst@number\psxunit mul exch >
\makeatother
\begin{document}
% Andersrum:
% Definiere über phi und beta
% phi Kreisbogen von (a,0,a) nach (a cos phi, a sin phi, a)
% beta Kreisbogen von (a cos phi, a sin phi, a)
% nach P=(a cos phi cos beta, a sin phi cos beta, a + a sin beta)
% ^P ist bei (2a+Pz)/(2a-Pz)*(Px, Py, 0)
\def\PHI/{33}
\def\BETA/{30}
\def\A/{4}
\def\outer/{4}
\def\inner/{2.5}
\def\B/{2,2}
\def\offset/{0.3}
% P = (a cos phi cos beta, a sin phi cos beta, a + a sin beta)
\def\Px/{\A/ \PHI/ cos mul \BETA/ cos mul}
\def\Py/{\A/ \PHI/ sin mul \BETA/ cos mul}
\def\Pz/{\A/ \BETA/ sin mul \A/ add}
\def\phicolor/{red}
\def\betacolor/{blue}
\SpecialCoor
\begin{pspicture}(-7,-9)(9,9)
  \footnotesize%
  \psset{Alpha=75,Beta=20, arrowscale=2}
  
  %% Nodes:
  %% NOTE: \pstThreeDNode converts fromn 3D to 2D. These newly created nodes can
  %% currently only be used with 2D pstricks functions:
  \pstThreeDNode(0,0,\A/ 2 mul){N}
  \pstThreeDNode(0,0,\A/){M}
  \pstThreeDNode(\Px/, \Py/, \Pz/){P}
  \pstThreeDNode(0, 0, \A/){PAxis}

  \pstThreeDPlaneGrid[planeGrid=xy,linecolor=gray](-5,-5)(7,8)
  %% (Option A) Sphere:
  % \pstThreeDSphere[SegmentColor={[cmyk]{.3,0,0,0}},linecolor=gray!10,increment=10]%
  % (0,0,\A/){\outer/}
  %% (Option B) Circle:
  \pscircle(M){\outer/} %%

  %% Circles:
  \pstThreeDEllipse[beginAngle=0,endAngle=360,linecolor=gray,linestyle=dashed]%
  (0,0,\A/)(\outer/,0,0)(0,\outer/,0)
  \pstThreeDEllipse[beginAngle=90,endAngle=-90,linecolor=gray,linestyle=solid]%
  (0,0,\A/)(\outer/,0,0)(0,\outer/,0)
  \pstThreeDEllipse[beginAngle=0,endAngle=360,linecolor=gray,linestyle=dashed]%
  (0,0,\A/)(\outer/,0,0)(0,0,\outer/)
  \pstThreeDEllipse[beginAngle=90,endAngle=-90,linecolor=gray,linestyle=solid]%
  (0,0,\A/)(\outer/,0,0)(0,0,\outer/)


  %% Labels "N" and "S":
  \pstThreeDPut[origin=t](0,0,0 \offset/ sub){S}
  \pstThreeDPut[origin=b](0 \offset/ sub,0 \offset/ sub,\A/ 2 mul \offset/ add){N}

  %% Ellipsis Phi:
  \pstThreeDEllipse[beginAngle=0,endAngle=\PHI/,linecolor=\phicolor/,arrows=->]%
  (0,0,\A/)(\inner/,0,0)(0,\inner/,0)
  % \pstThreeDEllipse[beginAngle=0,endAngle=\PHI/,linecolor=\phicolor/,arrows=->]%
  % (0,0,\A/)(\inner/,0,0)(0,\inner/,0)
  %% Label Phi (placed at phi/2):
  \pstThreeDPut[origin=t](\inner/,\PHI/ 2 div sin \inner/ mul,\A/ \offset/ add)%
  {\color{\phicolor/}{$\phi$}}

  %% Ellipsis Beta:
  \pstThreeDEllipse[beginAngle=0,endAngle=\BETA/,linecolor=\betacolor/,arrows=->]%
  (0,0,\A/)(\inner/ \PHI/ cos mul,\inner/ \PHI/ sin mul,0)(0,0,\inner/)
  %% Label Beta:
  \pstThreeDPut[origin=l]%
  (\inner/ \PHI/ cos mul, 
  \inner/ \BETA/ sin mul .1 sub,
  \A/ \BETA/ sin mul \A/ 2 div add .5 add)%
  {\color{\betacolor/}{$\beta$}}
  
  %% Line "A" to "P":
  \pstThreeDLine[linecolor=blue](0, 0, \A/)(\Px/, \Py/, \Pz/)
  %% Alternative using 2D function and results from \pstThreeDNode:
  % \psline[linecolor=red](M)(P)
  %% Label "P":
  \pstThreeDPut[origin=b](\Px/ \offset/ add, \Py/ \offset/ add, \Pz/ \offset/ add)%
  {$P$}

  %% P hat: (2a+Pz)/(2a-Pz)*(Px, Py, 0)
  %% TODO: Fix coordinate?:
  \pstThreeDNode(
  \A/ 2 mul \Pz/ add \A/ 2 mul \Pz/ sub div \Px/ mul, 
  \A/ 2 mul \Pz/ add \A/ 2 mul \Pz/ sub div \Py/ mul, 
  0){Phat}
  \psline[linecolor=black](P)(Phat)
  \psline[linecolor=black](P)(N)
  % \psline[linecolor=green](Phat)(N)

  %% Brace "a" (needs pstricks-add; older versions need hack in header):
  %% This is a 2D function:
  \psbrace[bracePos=0.75,ref=rC,rot=180,linewidth=.5pt,braceWidth=.5pt]%
  (PAxis)(S){$a$}

  %% Helper lines:
  {\psset{linecolor=gray,linestyle=dashed,linewidth=0.2pt,drawCoor}
    %% Phi:
    \pstThreeDLine(0,0,\A/)(\outer/ \PHI/ cos mul,\outer/ \PHI/ sin mul, \A/)
    \pstThreeDLine(0,0,\A/)(\outer/,0, \A/)
    %% optional:
    % \pstThreeDDot(\inner/ \PHI/ cos mul,\inner/ \PHI/ sin mul, \A/)
    % \pstThreeDDot(\inner/,0, \A/)
    %% P:
    %% optional:
    % \pstThreeDDot(\Px/, \Py/, \Pz/)
  }

  %% Coordinate axes:
  \pstThreeDCoor[linecolor=darkgray,xMin=-5,xMax=5,yMin=-5,yMax=7,zMin=0,zMax=9,%
  nameX=$x$ $\xi$,nameY=$y$ $\eta$,nameZ=$\zeta$]

\end{pspicture}
\end{document}

%%% Local Variables: 
%%% mode: latex
%%% LaTeX-command-style: (("" "ps4pdf %S %t"))
%%% TeX-master: t
%%% End: 
