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.

  • tikz-3dplot may come in handy.
    – Manuel
    Mar 30, 2014 at 13:27

3 Answers 3


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


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


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

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

    \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] ;

    \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 ;


Metapost code :

prologues := 2 ;

%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) ;

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 ;    

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

  • Thank you for your examples - I did not know about MetaPost, this really looks like a promising alternative to tikz - much easier to understand!
    – flawr
    Mar 30, 2014 at 21:18
  • @Tarass: I stored your metapost code as spherical-triangle.mp, then I run mpost spherical-triangle.mp. But the result does not look like your result. The labels in the red triangle are missing. What did I do wrong? Oct 3, 2014 at 11:20
  • @moose Nothing wrong, just use includegraphics in a tex document. If you use pdf tex output such as pdflatex or lualatex ... add outputtemplate := "%j-%c.mps"; in the metapost file.
    – Tarass
    Oct 3, 2014 at 13:23

Here is a first attempt at an answer, based on tikz-3dplot, as suggested by @Manuel above. Consider the following MWE:


\tdplotsetmaincoords{\alpha}{\beta} % Perspective on the main coordinate system
\pgfmathsetmacro{\radius}{0.8} % radius of the circle

% Draw circle in the un-rotated coordinates
\draw[blue,tdplot_screen_coords] (0,0,0) circle (\radius);

% draw coordinate vectors for reference
\draw[->] (-1,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[->] (0,-1,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[->] (0,0,-1) -- (0,0,1) node[anchor=south]{$z$};

% draw the "visible" and  "hidden" portions of the circumference as a solid and dashed semi-circles, parametrically 
\draw[red,domain={-180+\beta}:\beta] plot ({\radius*cos(\x)}, {\radius*sin(\x)});
\draw[red,dashed,domain=\beta:{180+\beta}] plot ({\radius*cos(\x)}, {\radius*sin(\x)});

% Change coordinate system, rotate about the reference x and y axis
\draw [green,tdplot_rotated_coords,domain=160:340] plot ({\radius*cos(\x)}, {\radius*sin(\x)});
\draw [green,dashed,tdplot_rotated_coords,domain=-20:160] plot ({\radius*cos(\x)}, {\radius*sin(\x)});


which results in

enter image description here

I adapted one of the examples used in the tikz-3dplot manual to define a three-dimensional coordinate system, draw two semicircles on it (one solid, one dashed). I then changed the coordinate system to produce the intersecting circle.

It could be the basis for what you need: I would need to work out where, in the new coordinate system, solid semi-circle should meet the dashed one and how to fill the intersections with different colors.

EDIT: I changed the way in which the coordinate system is updated. Also, I drew semi-circles using the procedure suggested in Draw arc in tikz when center of circle is specified

  • Thank you very much for your effort, this really helped me. One further question: Is it possible to draw an 'angle-symbol' (little arc with the corresponding greek letter) - as @Tarass did it in Metapost - on the intersection of those two circles?
    – flawr
    Mar 30, 2014 at 21:14
  • For the intersection, you need the intersections library in TikZ, like @Tarass used in the answer below. I'm not very proficient in it, but you can find examples here: texample.net/tikz/examples/feature/intersections
    – MatteoS
    Mar 31, 2014 at 13:52

\def\radius{4 }\def\PhiI{20 }\def\PhiII{50 }
\def\RadIs{\radius \PhiI sin mul}
\def\RadIc{\radius \PhiI cos mul}



enter image description here

  • Very nice. One of the dashed circle is not great circle, it should pass through the pole ?
    – Tarass
    Mar 31, 2014 at 16:10
  • 1
    Yes, that was intended to show that it is possible.
    – user2478
    Mar 31, 2014 at 16:15

Not the answer you're looking for? Browse other questions tagged .