[Tex/LaTex] Spherical triangles and great circles

tikz-pgf

I want to draw an image of a non-shaded sphere (just a circular border) with three intersecting great circles that are solid on the visible side and dashed on the back side. Further I want to be able to mark angles, sides and points as well as radiuses.

In the end I need to be able to draw Images like this one:

enter image description here

PS: I already searched through many tutorials with TikZ and other packages, the main problems were that I was not able to draw circles other than longitude or latitude circles.

I am thankful for any tutorials or example documents that show solutions for this.

Best Answer

It's very easy to draw, but as often difficult to fill because of the big lake in tikz with using pathes especially drawing following them. With metapost it's peace of cake. Here the intersection points are calculated, but I don't know how to draw a cycle following the pathes, when buildcycle does that in one command in metapost...

With Metapost (see code below) :

enter image description here

With Tikz :

enter image description here

\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}

\newcommand{\InterSec}[3]{%
    \path[name intersections={of=#1 and #2, by=#3, sort by=#1,total=\t}]
        \pgfextra{\xdef\InterNb{\t}}; }

\begin{document}
\begin{tikzpicture}

\draw[thick] (0,0) circle (2) ;

\foreach \angle[count=\n from 1] in {-5,225,290} {

    \begin{scope}[rotate=\angle]
    \path[draw,dashed,name path global=d\n] (2,0) arc [start angle=0,
                            end angle=180,
                            x radius=2cm,
                            y radius=1cm] ;
    \path[draw,name path global=s\n] (-2,0) arc [start angle=180,
                        end angle=360,
                        x radius=2cm,
                        y radius=1cm] ;
    \end{scope}
    }

    \InterSec{s1}{s2}{I3} ;
    \InterSec{s1}{s3}{I2} ;
    \InterSec{s3}{s2}{I1} ;
    \fill[red] (I1)--(I2)--(I3)--cycle ;

    \InterSec{d1}{d2}{J3} ;
    \InterSec{d1}{d3}{J2} ;
    \InterSec{d3}{d2}{J1} ;
    \fill[blue] (J1)--(J2)--(J3)--cycle ;

\end{tikzpicture}
\end{document}

Metapost code :

prologues := 2 ;
verbatimtex
%&latex
\documentclass[10pt]{article}
\usepackage{amsmath,amsfonts,amssymb}
\begin{document}
\scriptsize
etex;

%input Macros-nk ;

u := 1.5cm ;

%##############
\beginfig(1) %#
%##############

path p[] ;

draw fullcircle scaled 4u withpen pencircle scaled 1pt ;

p0 := halfcircle scaled 4u yscaled .5;

for i=0 upto 2 :
    p[i+1] := p0 rotated (-5+60*i) ;
    p[i+4] := p0 rotated (-5+60*i+180) ;
    endfor 

fill buildcycle(p1,p2,p3) withcolor .7[red,white] ;
fill buildcycle(p4,p5,p6) withcolor .7[blue,white] ;

z1 = p1 intersectionpoint p2 ;
z2 = p2 intersectionpoint p3 ;
z3 = p3 intersectionpoint p1 ;

for i=1 upto 2 :
    draw p[i] withpen pencircle scaled .3pt ;
    draw p[i+3] withpen pencircle scaled .3pt dashed evenly scaled .5;
    draw z[i]--(-z[i]) withpen pencircle scaled .3pt dashed evenly ;    
    endfor 

draw halfcircle scaled (.6*u) rotated 90 shifted z1
        cutafter p2 cutbefore p1
        withpen pencircle scaled .1pt ; 
draw halfcircle scaled (.6*u) shifted z2
        cutafter p3 cutbefore p2
        withpen pencircle scaled .1pt ; 
draw halfcircle scaled (.45*u) rotated -90 shifted z3
        cutafter p1 cutbefore p3
        withpen pencircle scaled .1pt ; 

label(btex $\alpha$ etex , z1 shifted (-.2u,-.1u)) ;
label(btex $\beta$ etex , z2 shifted (0u,.2u)) ;
label(btex $\gamma$ etex , z3 shifted (.1u,-.1u)) ;

%##############
endfig;      %#1
%##############

end
Related Question