3

Actually a question. I can not find a simple and elegant answer. The use of arcs makes me despondent.

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{intersections}

\begin{document}
    \begin{tikzpicture}
        \draw[name path=circles] (0,0) circle (4 and 2) circle (3 and 1);
        \path[name path=line1] (0,0) -- (10:5);
        \path[name path=line2] (0,0) -- (-10:5);
        \draw[name intersections={of=circles and line1}] (0,0) -- (intersection-1);
        \draw[name intersections={of=circles and line2}] (0,0) -- (intersection-1);
    \end{tikzpicture}
\end{document}

enter image description here

2 Answers 2

5
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip  (0,0) -- (10:5) -- (-10:5) -- cycle;
\fill[pink, even odd rule] (0,0) ellipse[x radius=4, y radius=2] ellipse[x radius=3, y radius=1];
\end{scope}
\draw (0,0) ellipse[x radius=4, y radius=2] ellipse[x radius=3, y radius=1];
\draw (0,0) -- (10:5) (0,0) -- (-10:5);
\end{tikzpicture}
\end{document}

Two concentric ellipses with filled section

4

Here's an answer using the spath3 library, which works by splitting the elliptical and line paths where they intersect and then constructing a new path by welding together pieces of the resulting paths.

\documentclass{article}
%\url{https://tex.stackexchange.com/q/652890/86}
\usepackage{tikz}
\usetikzlibrary{intersections,spath3}

\begin{document}
\begin{tikzpicture}
\path[spath/save=circles] (0,0)
circle[x radius=4, y radius=2]
circle[x radius=3, y radius=1]
;
% the overlay key means that these don't add to the picture size,
% also, a single path here simplifies the code later
\path[spath/save=lines,overlay] (10:5) -- (0,0) -- (-10:5);

% split the paths where they overlap each other
\tikzset{
  spath/split at intersections={circles}{lines},
  % save the components of the paths
  spath/get components of={circles}\circlesCpts,
  spath/get components of={lines}\linesCpts,
}

\fill[
  magenta,
  % takes a little experimenting to get the order right ...
  spath/use={\getComponentOf\circlesCpts{3}},
  spath/use={\getComponentOf\linesCpts{2},weld},
  spath/use={\getComponentOf\circlesCpts{6},reverse,weld},
  spath/use={\getComponentOf\linesCpts{4},weld},
];

% draw the ellipses now so that they are over the top of the
% filled region
\draw[ultra thick, spath/use={circles}];

\end{tikzpicture}
\end{document}

Region filled as requested in the question

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.