答案1
欢迎!已经有很多类似的问题,其中很多都有很好的答案。这个答案试图让绘制土豆形状的边界更方便一些。给定一组 a 中的对象local bounding box
,它会在该 周围绘制一个有点不规则的椭圆形边界local bounding box
。相应的范围可用于其他目的,例如附加name prefix
。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,fill,inner sep=1.4pt,outer sep=0pt},
>={Stealth[bend,length=4.5pt,inset=1pt]}]
\begin{scope}[local bounding box=R,name prefix=R-]
\path node[bullet,label=above:$a$](a){}
(1,0.6) node[bullet,label=above:$b$](b){}
(-0.2,-1) node[bullet,label=below:$a+b$](aplusb){}
(1.3,-0.8) node[bullet,label=below:$a\cdot b$](adotb){};
\end{scope}
\pgfmathsetseed{42}
\draw plot[smooth cycle,domain=0:330,samples=11,variable=\t,tension=0.7]
([xshift={0.25*(1+rnd)*cos(\t)*1cm+0.75*cos(\t)*1cm},
yshift={0.5*(1+rnd)*sin(\t)*1cm}]R.\t);
%
\begin{scope}[local bounding box=S,xshift=6cm,name prefix=S-]
\path node[bullet,label=above:$\phi(a)$](a){}
(1.4,0.4) node[bullet,label=above:$\phi(b)$](b){}
(0.2,-1.3) node[bullet,label=below:$\phi(a+b)$](aplusb){}
(1.6,-0.6) node[bullet,label=below:$\phi(a\cdot b)$](adotb){};
\end{scope}
\draw plot[smooth cycle,domain=0:330,samples=11,variable=\t,tension=0.7]
([xshift={0.25*(1+rnd)*cos(\t)*1cm+0.75*cos(\t)*1cm},
yshift={0.5*(1+rnd)*sin(\t)*1cm}]S.\t);
%
\path (R.120) node[above=2.5em]{$R$} (S.60) node[above=2.5em]{$S$};
\begin{scope}[->]
\begin{scope}[dashed]
\foreach \X in {R,S}
{\draw (\X-a) -- (\X-aplusb);
\draw (\X-b) -- (\X-adotb);
\draw (\X-a) -- (\X-adotb);
\draw (\X-b) -- (\X-aplusb);
}
\end{scope}
\foreach \X [count=\Y] in {a,b,adotb,aplusb}
{\draw (R-\X) to[bend right={sign(\Y-2.5)*20}]
node[above,pos={0.5+0.1*pow(-1,\Y)*sign(\Y-2.5)}]{$\phi$} (S-\X);}
\end{scope}
\end{tikzpicture}
\end{document}
总体而言,将屏幕截图转换为 LaTeX 代码并不是本网站的真正目的。当然,这样的问题通常会得到答案,但用户通常会从概念性更强的问题中受益更多,在这些问题中,原帖者会发布一个具体的代码来展示他们尝试过的方法。