我试图让中间的圆圈适合两个较大的圆圈:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}
\coordinate (x0) at (-2.5,0);
\coordinate (x1) at (2,0);
\coordinate (y) at (0,0);
\filldraw[fill=lime,fill opacity=0.3] (x0) circle (4);
\filldraw[fill=lime,fill opacity=0.3] (x1) circle (3.5);
\filldraw[fill=blue,fill opacity=0.2]
let \p0 = ($(x0) - (y)$) in
let \p1 = ($(x1) - (y)$) in
(y) circle
({min(4 - veclen(\x0,\y0),3.5 - veclen(\x1,\y1))});
\node at (x0) {\textbullet};
\node[below left=20pt of x0] {$\operatorname{Ball}(x_0;r_0)$};
\node at (x1) {\textbullet};
\node[below right=20pt of x1] {$\operatorname{Ball}(x_1;r_1)$};
\node at (y) {\textbullet};
\node[below=0.1pt of y] {$y$};
\end{tikzpicture}
\end{document}
r_0 - d(x_0,y)
我认为取和的最小值r_1 - d(x_1,y)
是可行的,但它却给出了上述奇怪的结果。
编辑:中间圆的中心将移到轴以外的其他地方。半径必须适应中心。
答案1
您必须在计算中指定半径的单位:
(y) circle
({min(4cm - veclen(\x0,\y0),3.5cm - veclen(\x1,\y1))});
答案2
这里不需要,veclen
因为相关点都在轴上,所以它只是 1.5
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}%grrr
\usepackage{amsmath}%grrr
\begin{document}
\begin{tikzpicture}
\coordinate (x0) at (-2.5,0);
\coordinate (x1) at (2,0);
\coordinate (y) at (0,0);
\filldraw[fill=lime,fill opacity=0.3] (x0) circle (4);
\filldraw[fill=lime,fill opacity=0.3] (x1) circle (3.5);
\filldraw[fill=blue,fill opacity=0.2] (y) circle (1.5);
\node at (x0) {\textbullet};
\node[below left=20pt of x0] {$\operatorname{Ball}(x_0;r_0)$};
\node at (x1) {\textbullet};
\node[below right=20pt of x1] {$\operatorname{Ball}(x_1;r_1)$};
\node at (y) {\textbullet};
\node[below=0.1pt of y] {$y$};
\end{tikzpicture}
\end{document}
答案3
这是另一个解决方案,它只需要指定两个圆,其余部分自行计算。有关结果,请参阅其他答案。
\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[x=1cm,y=1cm]
\coordinate (A) at (-2.5,0); % center first circle
\newcommand\ra{4cm} % radius first circle
\coordinate (B) at (2,0); % center first circle
\newcommand\rb{3.5cm} % radius first circle
\coordinate (BA) at ($(B)!\rb!(A)$); % point on circle around B towards A
\coordinate (AB) at ($(A)!\ra!(B)$); % point on circle around A towards B
\coordinate (C) at ($0.5*(BA)+0.5*(AB)$); % center third circle
\filldraw[fill=lime,fill opacity=0.3] (A) circle (\ra);
\node at (A) {\textbullet};
\node[below left=20pt of A] {$\operatorname{Ball}(x_0;r_0)$};
\filldraw[fill=lime,fill opacity=0.3] (B) circle (\rb);
\node at (B) {\textbullet};
\node[below right=20pt of B] {$\operatorname{Ball}(x_1;r_1)$};
\filldraw[fill=blue,fill opacity=0.2]
let \p1=($(C)-(AB)$) in
(C) circle ({veclen(\x1,\y1)});
\node at (C) {\textbullet};
\node[below=0.1pt of C] {$y$};
\end{tikzpicture}
\end{document}