두 원 사이의 교차점을 식별하고 겹쳐진 영역을 색칠하는 방법은 무엇입니까?

두 원 사이의 교차점을 식별하고 겹쳐진 영역을 색칠하는 방법은 무엇입니까?
\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}

여기에 이미지 설명을 입력하세요

답변1

패키지 는 두 원의 교차점을 계산하는 tkz-euclide매크로를 제공합니다 . \tkzInterCC따라서 선은 반경 1cm의 \tkzInterCC[R](A,1 cm)(B,1.5 cm) \tkzGetPoints{M1}{N1}중심에 있는 원 과 반경 1.5cm의 중심에 있는 원이 교차점을 찾도록 지정합니다. 매크로는 교차점의 이름을 및 로 지정합니다 .AB\tkzGetPoints{M1}{N1}M1N1

\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}

교차 영역(순서 개수) 뒤에 원을 그리는 것이 유용하다고 생각합니다. Gummi의 출력은 다음과 같습니다.

여기에 이미지 설명을 입력하세요

답변2

의견에서 말했듯이 겹치는 영역을 채우기 위해 교차점이 필요하지 않습니다. 하지만 꼭 필요한 경우 교차로 라이브러리를 사용하여 찾을 수 있습니다. 아래 코드는 이에 대한 예를 보여줍니다.

\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}

나는 또한 교차로 라이브러리 없이 이 작업을 시도했습니다. 첫 번째 교차점은 두 번째 중심으로 이어지는 경로에서 발견됩니다. 나는 다음을 사용하여 두 번째 것을 찾으려고 노력했습니다.

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

하지만 라텍스에서는 불완전한 \iffalse 오류가 발생합니다. 이 문제를 해결하는 방법을 아는 사람이 있다면?


편집하다내 답을 찾았어여기교차 라이브러리 없이 다른 솔루션을 만들 수 있도록 \pgfmathparse를 제거해야 합니다.

\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}

답변3

Alain이 언급했듯이 intersections교차점을 찾기 위해 도서관을 선택할 수 있습니다.

나머지 원을 배경색으로 채워도 괜찮다면 다음 한 줄로 원의 교차점을 채울 수 있습니다.

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

먼저 강조 색상으로 전체 경로(두 원의 결합)를 채운 다음 를 사용하여 postaction배경색으로 나머지(대칭 차이)를 다시 그립니다 even odd rule.

관련 정보