[Tex/LaTex] Drawing a hyperbolic trajectory

pgfplotstikz-pgf

In Drawing the Celestial Sphere with Tikz Package, they use pspicture. Is there a way to use pspicture inside of tikz? I want to have a hyberbola pass by the Earth with a periapsis of 500km (scaled to the paper of course).

\documentclass{article}
\usepackage{pst-map3d, tikz, pgf}
\begin{document}

\begin{center}
  \begin{tikzpicture}
    \pgfmathsetmacro{\e}{1.44022}
    \pgfmathsetmacro{\a}{1}
    \pgfmathsetmacro{\b}{\a*sqrt((\e)^2 - 1)}
    \draw plot[domain = -2:2] ({\a*cosh(\x)}, {\b*sinh(\x)});
    \begin{pspicture}(-4,-4)(4,4)
      \psset{RotX = -23, RotZ = 30, PHI = 46.5833, THETA = 0.3333,
             visibility = false, Decran = 15,
             path
             = /usr/local/texlive/2012/texmf-dist/tex/generic/pst-geo/data}
      \WorldMapThreeD[circles = false, blueEarth = false]
      \WorldMapThreeD[circles = false, visibility = true, opacity = 0.7]
      \psmeridien[visibility = true]{13.33}
      \psparallel[visibility = true]{52.51}
      \mapputIIID(13.33,52.51){Berlin}
      \psparallel[visibility = true]{0}
    \end{pspicture}
  \end{tikzpicture}
\end{center}
\end{document}

Best Answer

Here is a solution, without fancy drawing for the Earth, but which shows the varying solar radiation as the Earth travels along the hyperbolic orbit.

Note: an elliptical version is available here.

enter image description here

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{center}
  \begin{tikzpicture}[scale=2]
    \pgfmathsetmacro{\e}{1.44022}               % eccentricity of the hyperbola
    \pgfmathsetmacro{\a}{1}
    \pgfmathsetmacro{\b}{\a*sqrt((\e)^2 - 1)}
    \pgfmathsetmacro{\c}{sqrt((\a)^2+(\b)^2}    % distance from centre to focus
    \pgfmathsetmacro{\Sunradius}{0.2}           % Sun radius
    \pgfmathsetmacro{\Earthradius}{0.05}        % Earth radius
    \pgfmathsetmacro{\thetamax}{1.5}

    \draw plot[domain = -\thetamax:\thetamax] ({\a*cosh(\x)}, {\b*sinh(\x)});
    \draw (\c,0) circle (1pt);

    \shade[%
        top color=yellow!70,%
        bottom color=red!70,%
        shading angle={45},%
    ] (\c,0) circle (\Sunradius);

    % This function computes the direction in which light hits the Earth.
    \pgfmathdeclarefunction{f}{1}{%
    \pgfmathparse{
      ((-\c+\a*cosh(#1))<0) * ( 180 + atan( \b*sinh(#1)/(-\c+\a*cosh(#1)) ) ) 
        +
      ((-\c+\a*cosh(#1))>=0) * ( atan( \b*sinh(#1)/(-\c+\a*cosh(#1)) ) ) 
    }
  }


  % This function computes the distance between Earth and the Sun,
  % which is used to calculate the varying radiation intensity on Earth.
  \pgfmathdeclarefunction{d}{1}{%
    \pgfmathparse{ sqrt((-\c+\a*cosh(#1))^2+(\b*sinh(#1))^2) }
  }

  \pgfmathtruncatemacro{\N}{8}  % an even number is best here
  \pgfmathsetmacro{\thetaoffset}{.15*\thetamax}
  \foreach \k in {0,1,...,\N}{
    \pgfmathsetmacro{\theta}{(\thetamax-\thetaoffset)*(2*\k/\N-1)}
      \pgfmathsetmacro{\radiation}{100*(1-\c)/d(\theta))^2}
      \colorlet{Earthlight}{yellow!\radiation!blue}
        \shade[
          top color=Earthlight,
          bottom color=blue,
          shading angle={90+f(\theta)},
        ] ({\a*cosh(\theta)}, {\b*sinh(\theta)}) circle (\Earthradius);

    }
    \end{tikzpicture}
\end{center}
\end{document}

EDIT: with a nice .png of the Earth at the focus instead.

enter image description here


The picture I used is adapted from the one posted there.

enter image description here

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{center}
  \begin{tikzpicture}[scale=2]
    \pgfmathsetmacro{\e}{1.44022}               % eccentricity of the hyperbola
    \pgfmathsetmacro{\a}{1}
    \pgfmathsetmacro{\b}{\a*sqrt((\e)^2 - 1)}
    \pgfmathsetmacro{\c}{sqrt((\a)^2+(\b)^2}    % distance from centre to focus
    \pgfmathsetmacro{\Earthradius}{0.1}        % Earth radius
    \pgfmathsetmacro{\UFOradius}{.03}
    \pgfmathsetmacro{\thetamax}{1.2}

    \draw plot[domain = -\thetamax:\thetamax] ({\a*cosh(\x)}, {\b*sinh(\x)});

    \path (\c,0) node(a) {\includegraphics[width=.5cm]{earth.png}};

  \pgfmathtruncatemacro{\N}{8}  % an even number is best here
  \pgfmathsetmacro{\thetaoffset}{.05*\thetamax}
  \foreach \k in {0,1,...,\N}{
    \pgfmathsetmacro{\theta}{(\thetamax-\thetaoffset)*(2*\k/\N-1)}
        \shade[top color=black,bottom color=gray]
            ({\a*cosh(\theta)}, {\b*sinh(\theta)}) circle (\UFOradius);

    }
    \end{tikzpicture}
\end{center}
\end{document}
Related Question