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.

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}
share|improve this question
    
Forgive me, I could not follow "hyberbola pass by the Earth with a periapsis of 500km", it would be better to have a schematic/graphic(atleast hand drawn) to show what you need.BTW pspicture is environment in PSTricks analogous to tikzpicture environment to tikz-pgf. I don't think they can be combined as their workflow is different. But the pdf output from pstricks can be attached to a node in TikZ. –  texenthusiast Apr 16 '13 at 5:58
    
Have you seen this? Perhaps you could adapt it to suit your needs... –  Jubobs Apr 16 '13 at 8:58
1  
You could try to put the pspicture in a node. –  Ulrike Fischer Apr 16 '13 at 9:25
    
@texenthusiast how do you put it in a node? –  dustin Apr 16 '13 at 11:22
1  
you can mix tikZ and PSTricks in any way as long as you use xelatex or the route latex->dvips->ps2pdf. But why can't you use only PSTricks? –  Herbert Apr 16 '13 at 11:43

1 Answer 1

up vote 5 down vote accepted

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}
share|improve this answer
    
Earth is the focus not a passing planet. –  dustin Apr 16 '13 at 11:20
    
Nice! I wouldn't bother changing the answer because of this point but... when you've got a higher density of 'snapshots' of the projectile, it makes it look like its moving slower in that region. For the case of an orbit (or a hyperbolic fly-by), the closest approach is where the trajectory moves fastest. –  User 17670 Apr 16 '13 at 14:08
1  
@user17670 True, but I think I'll leave that as an exercise :) –  Jubobs Apr 16 '13 at 15:41
    
@Jubobs I have been looking through the code so I guess I don't understand it fully. How can I adjust the distance between the path and the Earth? –  dustin Apr 16 '13 at 19:48
1  
@dustin Modify \a, which corresponds to the semi-major axis of the hyperbola. Keep it positive, though. Alternatively, you can decrease the size of both the Earth and the UFO to make everything appear further apart without modifying the trajectory. –  Jubobs Apr 16 '13 at 19:50

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.