5

As a follow-up to this question, Saturn has a tilt of 26°. But when I tilt Saturn, the colors of the rings change.

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\begin{scope}[rotate=26.73]
% Top half
\fill [gray!30] (0:1) arc (0:180:1) -- cycle;

% Ring
\path[inner color=black,outer color=yellow!20,even odd rule]    
    (0, 0) circle [x radius = 1.5, y radius = .25]
    (0, 0) circle [x radius = 1.7, y radius = .3]
    (0, 0) circle [x radius = 1.75, y radius = .33]
    (0, 0) circle [x radius = 1.95, y radius = .38]; 

% Bottom half
\fill [gray!30] (180:1) arc (180:360:1) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}

Here is what I get with rotate=0 and rotate=26.73.

without rotation with rotation

And what I'm trying to get goal

How can I get the rings to rotate without changing their color? How do I rotate the shading along with the object?

I tried to add shading angle=26.73, but the colors are still off:

\begin{tikzpicture}
\begin{scope}[rotate=26.73]
% Top half
\fill [gray!30] (0:1) arc (0:180:1) -- cycle;

% Ring
\path[inner color=black,outer color=yellow!20, even odd rule, shading angle=26.73]    
    (0, 0) circle [x radius = 1.5, y radius = .25]
    (0, 0) circle [x radius = 1.7, y radius = .3]
    (0, 0) circle [x radius = 1.75, y radius = .33]
    (0, 0) circle [x radius = 1.95, y radius = .38]; 

% Bottom half
\fill [gray!30] (180:1) arc (180:360:1) -- cycle;
\end{scope}
\end{tikzpicture}

also results in with rotation

2
  • If you draw only the rings, for example, you will see that it is a circular shading and so, shading rotations does not change the visual (a rotate circle is a circle again :-)). So, try to use linear shadings.
    – Sigur
    Apr 17, 2020 at 11:44
  • @Sigur How would I go about with linear shadings to get the same aspect as in the first image?
    – usernumber
    Apr 17, 2020 at 13:54

2 Answers 2

4

Is \rotatebox acceptable?

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\rotatebox{26.73}{%
\begin{tikzpicture}
% Top half
\fill [gray!30] (0:1) arc (0:180:1) -- cycle;

% Ring
\path[inner color=black,outer color=yellow!20,even odd rule]    
(0, 0) circle [x radius = 1.5, y radius = .25]
(0, 0) circle [x radius = 1.7, y radius = .3]
(0, 0) circle [x radius = 1.75, y radius = .33]
(0, 0) circle [x radius = 1.95, y radius = .38]; 

% Bottom half
\fill [gray!30] (180:1) arc (180:360:1) -- cycle;
\end{tikzpicture}%
}
\end{document}

enter image description here

EDIT

Well, understood. You can include your entire code inside a node:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% Top half
\node[rotate=26.37] at (0,0) {%
\begin{tikzpicture}
\fill [gray!30] (0:1) arc (0:180:1) -- cycle;

% Ring
\path[inner color=black,outer color=yellow!20,even odd rule]    
(0, 0) circle [x radius = 1.5, y radius = .25]
(0, 0) circle [x radius = 1.7, y radius = .3]
(0, 0) circle [x radius = 1.75, y radius = .33]
(0, 0) circle [x radius = 1.95, y radius = .38]; 

% Bottom half
\fill [gray!30] (180:1) arc (180:360:1) -- cycle;
\end{tikzpicture}
};
\end{tikzpicture}%
\end{document}

enter image description here

2
  • 1
    I have other things going on in the tikzpicture that I don't want rotated, so this doesn't quite cut it
    – usernumber
    Apr 17, 2020 at 13:09
  • I include another solution working inside the TikZ environment, in case it helps
    – user193767
    Apr 17, 2020 at 20:13
0

Here is a solution:

\documentclass[tikz]{standalone}
\begin{document}
\foreach \tilt in {-21.6,-21.2,...,21.6,21.2,20.8,...,-21.2}{
  \begin{tikzpicture}
    \fill[white] (-2.3,-1.3) rectangle (2.3,1.3);
    \begin{scope}[rotate=\tilt]
      % Top half
      \fill [gray!30] (0:1) arc (0:180:1) -- cycle;
      \colorlet{yellowhite}{yellow!20!white}
      \foreach \xrad[
      evaluate={\xrad as \yrad using \xrad/5.13},
      evaluate={\xrad as \cprop using int(\xrad/2.28*100)},
      ]in {1.5,1.52,...,1.8,1.98,2.00,...,2.28} {
        \fill[fill=yellowhite!\cprop!black,even odd rule]
        (0,0 ) circle [x radius=\xrad, y radius=\yrad]
        (0,0 ) circle [x radius=\xrad+0.02,y radius=\yrad+0.02/5.13];
      }
      % Bottom half
      \fill [gray!30] (180:1) arc (180:360:1) -- cycle;
    \end{scope}
  \end{tikzpicture}
}
\end{document}

enter image description here

1
  • Very nice Saturn :) if you create an effect 3D of the gray mass it is also more interesting. +1 for everyone.
    – Sebastiano
    Apr 17, 2020 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.