# TikZ: drawing 3 intersecting circles and shading

How can I draw the three intersection circles/ellipse with that shading paradigm (not necessarily the same colors) effectively? It appears that the original image doesn't have overlapping colors whereas I do.

1. Is there a better way to construct the drawing of the circles/ellipse than what I have done?
2. How can I make this a precise rotation for alignment with the equatorial
and ecliptic plane with the x axis ray?
3. How can I clip the circle at the origin out the all the filldraws so the blue sphere isn't over come by the background colors in it?
4. Also, how can I create the curve arrows to the point? I know I can use controls, but my control curves never look close to that.

When adding in the axis, I had to fiddle with the angle of ecliptic plane in order for the equatorial and the ecliptic plane to intersect at the x axis. However, this cant be precise just close.

Here is what I have now. The clips are really sloppy but I couldn't figure out a way to clip the area concisely.

\documentclass[convert = false, tikz]{standalone}
\usepackage[utf8]{inputenc}
\renewcommand{\rmdefault}{ppl}
\usepackage[scaled]{helvet}
\usepackage{courier}
\usepackage{eulervm}
\normalfont
\usepackage[T1]{fontenc}
\usepackage{textcomp}

\usepackage{amsmath}
\usepackage{tikz-3dplot}
\usetikzlibrary{intersections}
\tikzset{
partial ellipse/.style args = {#1:#2:#3}{
insert path = {+ (#1:#2) arc (#1:#2:#3)}
}
}
\begin{document}
\tdplotsetmaincoords{60}{130}
\begin{tikzpicture}[tdplot_main_coords,
every lable/.append style = {font = \tiny},
dot/.style = {outer sep = 0, inner sep = 0,
shape = circle, label = {#1}},
dot/.default =,
small dot/.style = {minimum size = .1cm, dot = {#1}},
small dot/.default =,
big dot/.style = {minimum size = .15cm, dot = {#1}},
big dot/.default =
]
\coordinate (O) at (0, 0);

\def\moonangle{45}
\def\sunangle{13.7}

\draw[-latex] (O) -- (6.5, 0, 0) node[font = \scriptsize, pos = 1.1]
{$$x(\gamma)$$};
\draw[-latex] (O) -- (0, 6, 0) node[font = \scriptsize, pos = 1.05] {$$y$$};
\draw[-latex] (O) -- (0, 0, 6.5) node[font = \scriptsize, above] {$$z$$};

start angle = 90, end angle = 270];
\draw[rotate = {\moonangle}, name path = moon] (O) ellipse[x radius = \rad,
\draw[rotate = {\sunangle}, name path = eclip] (O) ellipse[x radius = \rad,

\node[coordinate, name intersections = {of = moon and equa}] (P1) at
($(intersection-1)$) {};
\node[coordinate, name intersections = {of = moon and equa}] (P2) at
($(intersection-4)$) {};
\node[coordinate, name intersections = {of = moon and eclip}] (P3) at
($(intersection-4)$) {};
\node[coordinate, name intersections = {of = equa and eclip}] (P4) at
($(intersection-4)$) {};

\draw (P1) -- (P2);
\draw (O) -- (P3);

\begin{scope}
\begin{pgfinterruptboundingbox}
\clip (P1) -- ($(P1) + (3, -8)$) -- ($(P1) + (50, 20)$) --
(P2) -- cycle;
\end{pgfinterruptboundingbox}

\filldraw[green, opacity = .3, rotate = {\moonangle}] (O)
\filldraw[yellow, opacity = .3, rotate = {\sunangle}] (O)
\end{scope}

\begin{scope}
\begin{pgfinterruptboundingbox}
\clip (P1) -- ($(P1) + (-20, -5)$) -- ($(P1) + (20, 40)$) -- (P2) --
cycle;
\end{pgfinterruptboundingbox}

\filldraw[yellow, opacity = .3, rotate = {\sunangle}] (O)
\filldraw[green, opacity = .3, rotate = {\moonangle}] (O)
\end{scope}

\begin{scope}
\begin{pgfinterruptboundingbox}
\clip (O) -- (P4) -- +(1, 1) -- (P3) -- cycle;
\end{pgfinterruptboundingbox}

\filldraw[yellow, opacity = .3, rotate = {\sunangle}] (O)
\end{scope}

\filldraw[blue, opacity = .3] (O) circle[radius = .5cm];

\draw (180:.5cm) arc[x radius = .5cm, y radius = .25cm, start angle = 180,
end angle = 360];

\path[name path = greenwhich] (O) -- (128.5212:\rad);
\path[name path = moonrot] (O) -- (35:\rad);
\path[name path = sun] (O) -- (9:\rad);
\path[name intersections = {of = arc and greenwhich, by = P5}];
\path[name intersections = {of = moon and moonrot, by = P6}];
\path[name intersections = {of = sun and eclip, by = P7}];

\draw[-latex, blue, shorten <= .3cm, shorten >= .05cm] (O) -- (P5);

\node[fill = black, small dot = {right: }] at (P5) {};

\draw[-latex, purple, shorten <= .3cm, shorten >= .05cm] (O) -- (P6);

\node[fill = black, small dot = {right: }] at (P6) {};

\draw[-latex, red, shorten <= .3cm, shorten >= .05cm] (O) -- (P7);

\node[fill = orange, draw = orange, small dot = {right: }] at (P7) {};
\node[coordinate, name intersections = {of = arc and equa}, fill = black,
small dot = {left: }] (P8) at ($(intersection-2)$) {};

\draw[-latex] (226:4.75cm and 1.55cm) arc[x radius = 4.75cm,
y radius = 1.55cm, start angle = 226, end angle = 242];
\draw[rotate = {\moonangle}, -latex] (332:4.75cm and 2cm)
arc[x radius = 4.75cm, y radius = 2cm, start angle = 332, end angle = 348];
\draw[rotate = {\sunangle}, -latex] (327:5.25cm and 1.25cm)
arc[x radius = 5.25cm, y radius = 1.25cm, start angle = 327, end angle = 345];
\end{tikzpicture}
\end{document}


We can see the intersection looks good, but unless I am extremely luckily, it isn't precise.

-
\begin{UnproductiveComment} Your drawing looks great anyways. \end{UnproductiveComment} –  Henri Menke Aug 6 '13 at 15:29
@HenriMenke there is still room for improvement and some of the stuff I can't do so well like the curve arrows from the nodes to the key points or ellipses. I know controls should make them but mine never turn out so natural. –  dustin Aug 6 '13 at 15:35
Nice work! :-) I've been trying to figure out answers to some of your questions. Somehow I feel that it should be possible to use the TikZ 3D library to produce the ellipsoids, such that you don't have to do the y width calculations manually. I've also noticed that your sun orbit aren't on top of the moon orbit and equator ellipsoid in the small sector just right of the prime meridian. I also think you should have a slightly denser opacity (0.5?) to yield a more "3D effect" in the ellipsoids. The prime meridian should also be in a front layer. –  Holene Nov 26 '13 at 19:56