¿Cómo identificar los puntos de intersección entre dos círculos y colorear el área superpuesta?

¿Cómo identificar los puntos de intersección entre dos círculos y colorear el área superpuesta?
\documentclass[12pt]{article}
\usepackage{geometry} 
\usepackage[T1]{fontenc}    
\usepackage[latin1]{inputenc}   
\usepackage[brazil]{babel} 
\usepackage{tikz}               
\begin{center}
\begin{document}
\begin{tikzpicture}
\draw[ultra thick](0,0) circle [radius=1];
\draw[ultra thick](1.5,0.5) circle [radius=1.5];
\end{tikzpicture}
\end{center}
\end{document}

ingrese la descripción de la imagen aquí

Respuesta1

El tkz-euclidepaquete te ofrece una macro \tkzInterCCpara calcular los puntos de intersección de 2 círculos. Entonces, la línea \tkzInterCC[R](A,1 cm)(B,1.5 cm) \tkzGetPoints{M1}{N1}especifica que el radio del círculo centrado en Acon radio de 1 cm y el círculo centrado en Bcon radio de 1,5 cm encontrará los puntos de intersección. La macro \tkzGetPoints{M1}{N1}nombra los puntos de intersección como M1y N1.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}%IMPORTANT--recognizes points, lines, circles, etc
\begin{document}
\begin{tikzpicture}[scale=1]
\tkzDefPoint(0,0){A}  %center of circle 1
\tkzDefPoint(1.5,0.5){B}  %center of circle 2
\tkzInterCC[R](A,1 cm)(B,1.5 cm) \tkzGetPoints{M1}{N1} %get the intersection
% of circles centered at A with radius 1 and B with radius 1.5 and store as M1, N1
\begin{scope}
\tkzClipCircle(A,M1)
\tkzFillCircle[color=green!50,opacity=.5](B,M1)
\end{scope}
\tkzDrawCircle[R](A,1.cm) %draw circle 1 centered at A with radius 1
\tkzDrawCircle[R](B,1.5cm) %draw circle 2 centered at B with radius 1
\tkzDrawPoints[color=orange, fill=orange](M1,N1)%Draw points
\end{tikzpicture}
\end{document}

Me resulta útil dibujar los círculos después de la región de intersección (el orden cuenta). El resultado en Gummi se muestra a continuación:

ingrese la descripción de la imagen aquí

Respuesta2

Como se dice en el comentario, no necesita los puntos de intersecciones para llenar el área superpuesta. Pero si los necesita, puede utilizar la biblioteca de intersecciones para encontrarlos. El siguiente código muestra un ejemplo de esto.

\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[brazil]{babel}
\usepackage{tikz}
\usetikzlibrary{intersections}

\def\rayona{1}
\def\rayonb{1.5}
\def\interangle{90}

\begin{document}
\begin{tikzpicture}

% define first center
\coordinate (centera) at (0,0);

% Calculate second center based on radius and where is first intersection
\draw (centera) ++ (\interangle:\rayona) ++ (\interangle-90:\rayonb) coordinate (centerb);

% fill in first
\begin{scope}
\clip (centera) circle (\rayona);
\fill[black!15] (centerb) circle (\rayonb);
\end{scope}

% then draw the circles
\draw[ultra thick,name path=circlea] (centera) circle (\rayona);
\draw[ultra thick,name path=circleb] (centerb) circle (\rayonb);

%find intersections
\draw[name intersections = {of = circlea and circleb}] (intersection-1) node[red] {$\times$} node[above left]{Inter1} (intersection-2) node[red] {$\times$} node[below right]{Inter2};
\end{tikzpicture}
\end{document}

También intenté hacer esto sin la biblioteca de intersecciones. El primer cruce lo encontramos en el camino que conduce al segundo centro. Intenté encontrar el segundo usando

\draw (centera) ++ ({\pgfmathparse{\interangle-2*atan{\rayonb/\rayona}}\pgfmathresult}:\rayona) coordinate (inter2);

pero el látex me da un error \iffalse incompleto. ¿Si alguien sabe cómo solucionar este problema?


Editarencontré mi respuestaaquíEs necesario eliminar \pgfmathparse para poder encontrar otra solución, sin la biblioteca de intersecciones.

\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[brazil]{babel}
\usepackage{tikz}

\def\rayona{1}
\def\rayonb{1.5}
\def\interangle{90}

\begin{document}
\begin{tikzpicture}

% define first center
\coordinate (centera) at (0,0);

% Calculate second center based on radius and where is first intersection and define the first intersection
\draw (centera) ++ (\interangle:\rayona) coordinate (inter1) ++ (\interangle-90:\rayonb) coordinate (centerb);

% fill in first
\begin{scope}
\clip (centera) circle (\rayona);
\fill[black!15] (centerb) circle (\rayonb);
\end{scope}

% then draw the circles
\draw[ultra thick] (centera) circle (\rayona);
\draw[ultra thick] (centerb) circle (\rayonb);

%calculate the position of the second intersection
\draw (centera) ++ ({\interangle-2*atan{\rayonb/\rayona}}:\rayona) coordinate (inter2);;

% Use intersection
\draw (inter1) node[red] {$\times$} node[above left] {Inter1};
\draw (inter2) node[red] {$\times$} node[below right] {Inter2};
\end{tikzpicture}
\end{document}

Respuesta3

Como mencionó Alain, la intersectionsbiblioteca puede ser su elección para encontrar los puntos de intersección.

Si no te importa rellenar el resto de los círculos con el color de fondo, puedes rellenar la intersección de los círculos con esta frase:

\path[fill=yellow, postaction={fill=white, even odd rule, draw}] (0,0) circle (2) (2,.3) circle (3);

Primero llena todo el trazado (unión de ambos círculos) con tu color de resaltado, luego (usando postaction) vuelve a dibujar el resto (diferencia simétrica) con tu color de fondo, usando even odd rule.

información relacionada