[Tex/LaTex] TikZ: drawing 3 intersecting circles and shading

3dshadingtikz-pgf

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.

enter image description here

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}
\linespread{1.05}
\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\rad{5cm}
  \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\)};

  \draw (O) circle[radius = \rad];
  \draw[name path = arc] (90:\rad) arc[x radius = 3cm, y radius = \rad,
  start angle = 90, end angle = 270];
  \draw[name path = equa] (O) ellipse[x radius = \rad, y radius = 1.675cm];
  \draw[rotate = {\moonangle}, name path = moon] (O) ellipse[x radius = \rad,
  y radius = 2.25cm];
  \draw[rotate = {\sunangle}, name path = eclip] (O) ellipse[x radius = \rad,
  y radius = 1cm];

  \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)
    ellipse[x radius = \rad, y radius = 2.25cm];
    \filldraw[yellow, opacity = .3, rotate = {\sunangle}] (O)
    ellipse[x radius = \rad, y radius = 1cm];
    \filldraw[blue, opacity = .3] (O) ellipse[x radius = \rad,
    y radius = 1.675cm];
  \end{scope}

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

    \filldraw[blue, opacity = .3] (O) ellipse[x radius = \rad,
    y radius = 1.675cm];
    \filldraw[yellow, opacity = .3, rotate = {\sunangle}] (O)
    ellipse[x radius = \rad, y radius = 1cm];
    \filldraw[green, opacity = .3, rotate = {\moonangle}] (O)
    ellipse[x radius = \rad, y radius = 2.25cm];
  \end{scope}

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

    \filldraw[yellow, opacity = .3, rotate = {\sunangle}] (O)
    ellipse[x radius = \rad, y radius = 1cm];
  \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}

enter image description here


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

enter image description here

Best Answer

An alternative way to make complex 3D representations is to use TeXgraph.

TexGraph is a software assisting in the creation of mathematical graphs in the form of orders, and to export as text files in various formats: LaTeX (eepic macros), or pstricks or Pgf / Tikz (pgf macros), or Eps or PSF (eps + pSfrag) or pdf (eps conversion -> pdf) or svg ... There are also specific export to 3D.