12

I have a number of paths, quad-circles in this case, which intersect to define a complex region in the middle of the graph. How do I fill the A - B - C - D region in the image below? I prefer a solution that makes no assumptions on the formulation of the paths, i.e.: they can be Bezier curves with random control points instead of quadrant of a circle.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through}

\begin{document}
\begin{tikzpicture}
    \path[draw,clip] (0,0) rectangle (6,6);
    \node(circle 1)[draw, circle through={(6,0)}] at (0,0) {}; 
    \node(circle 2)[draw, circle through={(0,0)}] at (6,0) {};
    \node(circle 3)[draw, circle through={(6,0)}] at (6,6) {};
    \node(circle 4)[draw, circle through={(0,0)}] at (0,6) {};

    \coordinate[label=A](A) at (intersection 2 of circle 1 and circle 2);
    \coordinate[label=B](B) at (intersection 1 of circle 1 and circle 4);
    \coordinate[label=C](C) at (intersection 2 of circle 3 and circle 4);
    \coordinate[label=D](D) at (intersection 2 of circle 2 and circle 3);
\end{tikzpicture}
\end{document}

enter image description here

10

enter image description here

This Asymptote solution uses a function ABCD defined in asydef environment to draw a region of bounded by the four consecutively intersecting paths. However, some order of intersection is assumed. If the paths are absolutely random, (may not intersect, for example) than more checking is needed.

%
% xsect.tex :
%
\documentclass[10pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{lmodern}
\usepackage{subcaption}
\usepackage[inline]{asymptote}
\begin{asydef}
void ABCD(guide AB, guide BC, guide CD, guide DA
     ,pen linepen=deepblue+1.2bp
     ,pen areapen=red+1.4bp
     ,pen fillpen=palegreen){

  real tA[], tB[], tC[], tD[];
  pair A,B,C,D;

  tA=intersect(AB,DA); // tA[0] - AB time of intersection, t[1] - DA time of intersection
  tB=intersect(BC,AB); // tB[0] - BC time of intersection, t[1] - AB time of intersection
  tC=intersect(CD,BC); // tC[0] - CD time of intersection, t[1] - BC time of intersection
  tD=intersect(DA,CD); // tD[0] - DA time of intersection, t[1] - CD time of intersection

  A=point(AB,tA[0]);
  B=point(BC,tB[0]);
  C=point(CD,tC[0]);
  D=point(DA,tD[0]);

  guide area=buildcycle(AB,BC,CD,DA);

  draw(AB^^BC^^CD^^DA,linepen);
  filldraw(area,fillpen,areapen);

  label("$A$",A,2N);  
  label("$B$",B,2W);  
  label("$C$",C,2S);  
  label("$D$",D,2E);  

  dot(new pair[]{A,B,C,D},UnFill);
}
\end{asydef}
%
\begin{document}
%
\begin{figure}
\captionsetup[subfigure]{justification=centering}
\centering
\begin{subfigure}{0.49\textwidth}
\begin{asy}
size(200);
ABCD(
   arc(( 1,-1),2, 90,180)
  ,arc(( 1, 1),2,180,270)
  ,arc((-1, 1),2,-90,  0)
  ,arc((-1,-1),2,  0, 90)
);
\end{asy}
%
\caption{}
\label{fig:1a}
\end{subfigure}
%
\begin{subfigure}{0.49\textwidth}
\begin{asy}
size(200);
ABCD(
   (1,2)..(-1.2,0.1)..(-1.7,-1.8)
  ,(-2,1)..(-1,1)..(-0.5,0)..(0.5,-0.8)
  ,arc((-1, 1),2,-90,  0)
  ,(2,-1)..(2,0)..(0.5,1)..(0,1.7)
  ,olive+0.4bp
  ,orange+1.3bp
  ,lightyellow
);
\end{asy}
%
\caption{}
\label{fig:1b}
\end{subfigure}
\caption{}
\label{fig:1}
\end{figure}
%
\end{document}
%
% Process :
%
% pdflatex xsect.tex
% asy xsect-*.asy
% pdflatex xsect.tex
7

With PSTricks. Intersection is not necessary in this case as a simple logic can help you to find the angles at which the arcs start and stop. See the following explanation how to calculate the angles.

enter image description here

\documentclass[pstricks,border=12pt]{standalone}

\degrees[12]
\psset{dimen=monkey}

\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \psframe(-3,-3)(3,3)
    \pscustom*[linecolor=yellow]
    {
        \foreach \x/\y/\a in {-3/-3/1, 3/-3/4, 3/3/7, -3/3/10}
            {\psarc(\x,\y){6}{\a}{!\a\space 1 add}}
    }
    \foreach \x/\y/\a in {-3/-3/0, 3/-3/3, 3/3/6, -3/3/9}
        {\psarc(\x,\y){6}{\a}{!\a\space 3 add}}
\end{pspicture}
\end{document}

enter image description here

Miscellaneous

By changing {!\a\space 3 add} to {!\a\space 2 add}, we get a lens diaphragm.

\documentclass[pstricks,border=12pt]{standalone}

\degrees[12]
\psset{dimen=monkey}

\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \psframe(-3,-3)(3,3)
    \pscustom*[linecolor=yellow]
    {
        \foreach \x/\y/\a in {-3/-3/1, 3/-3/4, 3/3/7, -3/3/10}
            {\psarc(\x,\y){6}{\a}{!\a\space 1 add}}
    }
    \foreach \x/\y/\a in {-3/-3/0, 3/-3/3, 3/3/6, -3/3/9}
        {\psarc(\x,\y){6}{\a}{!\a\space 2 add}}
\end{pspicture}
\end{document}

enter image description here

6

Another approach by TikZ, where simple logic suggested by Marienplatz is applied. Thanks

Here the origin of circle 1 is my reference point and draw the first arc. What follows then is a pattern of 90 degree difference is repeated because this is how the remaining circles are drawn.

enter image description here

Code

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through}

\begin{document}
\begin{tikzpicture}
\path[draw,clip] (0,0) rectangle (6,6);
\node(circle 1)[draw, very thick,circle through={(6,0)}] at (0,0) {}; 
\node(circle 2)[draw, very thick,circle through={(0,0)}] at (6,0) {};
\node(circle 3)[draw, very thick,circle through={(6,0)}] at (6,6) {};
\node(circle 4)[draw, very thick,circle through={(0,0)}] at (0,6) {};
\coordinate[label=A](A) at (intersection 2 of circle 1 and circle 2);
\coordinate[label=B](B) at (intersection 1 of circle 1 and circle 4);
\coordinate[label=C](C) at (intersection 2 of circle 3 and circle 4);
\coordinate[label=D](D) at (intersection 2 of circle 2 and circle 3);
\fill[red] (30:6) arc (30:60:6) arc (120:150:6) arc(210:240:6) arc(300:330:6);
%\draw [black,thick] (30:6) arc (30:60:6) arc (120:150:6) arc(210:240:6) arc(300:330:6);
\end{tikzpicture}
\end{document}

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.