我画了一个维恩图,包含三个集合A
,B
和C
。每个圆的半径为$2\sqrt{2}$
,但我输入的是,2.828
因为TikZ
无法编译圆的代码(例如)\fill[draw=red] (-2,2) circle (2*sqrt(2));
。我该如何将半径输入为$2\sqrt{2}$
?
的中心circle A
是 (-2,2), 的中心circle B
是 (2,2), 的中心circle C
是 (0,-2)。circle A
和的circle B
交点是原点和 (0,4)。我想将 (表示 、 和 中的元素数)放置在原点2
和(0,4) 之间的垂直线上。我使用命令A
B
C
\draw[overlay,name path=circle A] (-2,2) circle (2.828);
,
\draw[overlay,name path=circle B] (2,2) circle (2.828);
,
和
\path[name intersections={of= circle A and circle B, by=F}];
找到其中一个。 TikZ
将交点定位在 (0,4)。我如何TikZ
找到它们两个并将其中一个称为intersection-AB1
?intersection-AB2
同样,我想将circle B
和的交点称为circle C
和intersection-BC1
,intersection-BC2
我想将 和 的交点称为和。circle B
我会发出命令circle C
intersection-AC1
intersection-AC2
\path[name path=lineAB] (intersection-AB1) -- (intersection-AB2);
,
\path[name path=lineBC] (intersection-BC1) -- (intersection-BC2);
,
和
\path[name path=lineAC] (intersection-AC1) -- (intersection-AC2);
,
我将把该交点称为P
,并将 定位2
在P
。 (我不希望P
在维恩图中有 ;稍后我将使用它来绘制其他六条线。另外,我不希望2
位于above right
点 的位置P
;我希望2
排版在点 的位置P
。)
在我的维恩图中,数字表示 中和中不包含的5
元素数,应排版在和之间的线段上。具体来说,如果我发出命令A
B
C
intersection-AB1
intersection-AB2
\path[name intersections={of= (intersection-AB1) -- (intersection-AB2) and circle C, by=PC}];
,
我想要将“5”排版在PC
交叉点-AB1或交叉点-AB2中间的位置(即圆 C 外面的位置)。
在我的维恩图中,A 中有 3 个元素既不在 B 中也不在 C 中。例如,如果intersection-BC1
是圆 B 和圆 C 的交点,而该交点位于圆 A 内,我想从 P 点画一条与圆intersection-BC1
A 相交的不可见射线。我将 称为射线ray.PA
,将 称为交点ray.PA
,将称为circle A
点intersection-PA
,我将它放置在和3
之间的中间位置。intersection-BC1
intersection-PA
最后要做的修改是,我不想使用above left
定位A
。我想将标签定位A
在 120 度角intersection-PA
。
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\usepackage{adjustbox}
\usepackage{mathtools}
\begin{document}
\begin{tikzpicture}
\draw[overlay,name path=circle A] (-2,2) circle (2.828);
\draw[overlay,name path=circle B] (2,2) circle (2.828);
\draw[overlay,name path=circle C] (0,-2) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (45:2.828) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (135:2.828) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (-90:2) circle (2.828);
\path[name intersections={of= circle A and circle B, by=F}];
\path[name intersections={of= circle A and circle C, by=G}];
\path[name intersections={of= circle B and circle C, by=H}];
%This positions a point, called S, halfway between the intersections of circle B and circle C.
\coordinate (S) at ($(G)!0.5!(H)$);
\draw[line width=0.1pt] (G) -- (H);
%This positions a point, called T, halfway between the intersections of circle A and circle C.
\coordinate (T) at ($(F)!0.5!(G)$);
\draw[line width=0.1pt] (F) -- (G);
%The following command puts the number 5 in the region $A \cap B$ and outside the region $A \cap B \cap C$.
\coordinate[label={5}] (A.intersect.B) at (0,2);
%These three rays start at P. They are used to position the names of the sets.
%I have to replace (0,0) with (P).
\path[overlay,name path=node A,blue,line width=0.1pt] (0,0) -- (120:6);
\path[overlay,name path=node B,blue,line width=0.1pt] (0,0) -- (60:6);
\path[overlay,name path=node C,blue,line width=0.1pt] (0,0) -- (-90:5);
\path[name intersections={of= node A and circle A, by=alpha}];
\path[name intersections={of= node B and circle B, by=beta}];
\path[name intersections={of= node C and circle C, by=gamma}];
\coordinate[label={above left:$A$}] (set A) at (alpha);
\coordinate[label={above right:$B$}] (set B) at (beta);
\coordinate[label={below:$C$}] (set C) at (gamma);
%These commands will be deleted. They label various points to more quickly see where the intersections
%F, G, and H are located.
\coordinate[label={above:$F$}] (F) at (F);
\coordinate[label={below left:$G$}] (G) at (G);
\coordinate[label={above right:$H$}] (H) at (H);
\node[outer sep=0pt,circle, fill,inner sep=1pt,label=below right:$S$] (S) at (S) {};
\node[outer sep=0pt,circle, fill,inner sep=1pt,label=above left:$T$] (T) at (T) {};
\end{tikzpicture}
\end{document}
答案1
使用sqrt
额外的牙套
\draw[overlay,name path=circle A] (-2,2) circle ({2*sqrt(2)});
对于第二个,指定第二个交点,也像
\path[name intersections={of= circle A and circle B, by={F,f}}];
画这些细线取决于你,因为我不知道要连接哪些点。
如果我理解的定位5
正确的话,你需要这样做:
\draw[line width=0.1pt] (F) -- node{5} (f) ;
使其位于 AB1 和 AB2 中间。
对于 120 度查询使用
\coordinate[label={above:$A$}] (set A) at (alpha.120);
再说一次,如果我理解正确的话,这应该能给你提供以下观点P
:
\path[line width=0.1pt,name path=ff] (F) -- node{5} (f) ;
\path[line width=0.1pt,name path=gg] (G) -- (g);
\path[name intersections={of= ff and gg, by=P}];
唉,看你的问题时我有点糊涂了。以下是可能不完整的代码。如果你能提供完整的手绘图就更好了。
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\usepackage{adjustbox}
\usepackage{mathtools}
\begin{document}
\begin{tikzpicture}
\draw[overlay,name path=circle A] (-2,2) circle ({2*sqrt(2)});
\draw[overlay,name path=circle B] (2,2) circle ({2*sqrt(2)});
\draw[overlay,name path=circle C] (0,-2) circle ({2*sqrt(2)});
\fill[pink!80,fill opacity=0.5,draw=red] (45:2.828) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (135:2.828) circle (2.828);
\fill[pink!80,fill opacity=0.5,draw=red] (-90:2) circle (2.828);
\path[name intersections={of= circle A and circle B, by={F,f}}];
\path[name intersections={of= circle A and circle C, by={G,g}}];
\path[name intersections={of= circle B and circle C, by={H,h}}];
%This positions a point, called S, halfway between the intersections of circle B and circle C.
\coordinate (S) at ($(G)!0.5!(H)$);
\draw[line width=0.1pt] (G) -- (H);
\draw[line width=0.1pt] (g) -- (h);
\draw[line width=0.1pt] (F) -- (g);
%This positions a point, called T, halfway between the intersections of circle A and circle C.
\coordinate (T) at ($(F)!0.5!(G)$);
\draw[line width=0.1pt] (F) -- (G);
\path[line width=0.1pt,name path=ff] (F) -- node{5} (f) ;
\path[line width=0.1pt,name path=gg] (G) -- (g);
\path[name intersections={of= ff and gg, by=P}];
\node at (P) {2};
\draw[name path=PHH] (P) -- ($(P)!6cm!0:(H)$); Change to `\path`
\path[name intersections={of= PHH and circle A, by=APHH}];
\path (H) -- node{3} (APHH);
%The following command puts the number 5 in the region $A \cap B$ and outside the region $A \cap B \cap C$.
%\coordinate[label={5}] (A.intersect.B) at (0,2);
%These three rays start at P. They are used to position the names of the sets.
%I have to replace (0,0) with (P).
\path[overlay,name path=node A,blue,line width=0.1pt] (0,0) -- (120:6);
\path[overlay,name path=node B,blue,line width=0.1pt] (0,0) -- (60:6);
\path[overlay,name path=node C,blue,line width=0.1pt] (0,0) -- (-90:5);
\path[name intersections={of= node A and circle A, by=alpha}];
\path[name intersections={of= node B and circle B, by=beta}];
\path[name intersections={of= node C and circle C, by=gamma}];
\coordinate[label={above:$A$}] (set A) at (alpha.120);
\coordinate[label={above right:$B$}] (set B) at (beta);
\coordinate[label={below:$C$}] (set C) at (gamma);
%These commands will be deleted. They label various points to more quickly see where the intersections
%F, G, and H are located.
\coordinate[label={above:$F$}] (F) at (F);
\coordinate[label={below left:$G$}] (G) at (G);
\coordinate[label={above right:$H$}] (H) at (H);
\node[outer sep=0pt,circle, fill,inner sep=1pt,label=below right:$S$] (S) at (S) {};
\node[outer sep=0pt,circle, fill,inner sep=1pt,label=above left:$T$] (T) at (T) {};
\end{tikzpicture}
\end{document}