从一个椭圆集到另一个椭圆集绘制一条线

从一个椭圆集到另一个椭圆集绘制一条线

我正在尝试绘制一个集合论图像,我需要绘制像这样的线条: 原始图像

我不知道如何指定行的开始和结束,所以我得到这个结果: LaTeX 图像

这是我的 latex 代码:

\documentclass{article} 
\usepackage{amssymb} 
\usepackage{tikz} 
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}

\begin{document} 
\tikzstyle{elps}=[ellipse,draw=black!50,thick]
\tikzstyle{crcl}=[circle,draw=black!50,thick]
\begin{tikzpicture}
\node[elps,fill=green!20,minimum width=4cm,minimum height=7cm] (G) at (0,0) {};
\node[below=of G] (Glabel) {$G$};
\node[crcl,minimum width=7cm] (H) [right=50pt of G] {};
\node[below=of H] (Hlabel) {$H$};
\node[elps,fill=yellow,minimum width=2.8cm,minimum height =5cm,label=30:$im(\mathcal{F})$] (im) [right=80pt of G] {};
\node[crcl,minimum width=2.5cm,fill=green] (ker) [left=70pt of H] {$ker(\mathcal{F})$};
\node[crcl,minimum width=0.02cm,fill=black,label=90:$I_H$] (p) [right=110pt of G] {};
\draw[->] (Glabel) to node[pos=0.5,above] {$\mathcal{F}$} (Hlabel);
\draw [-] (G) to (im);
\end{tikzpicture}
\end{document}

谢谢。

答案1

在 tikz 中绘制这个并不难。在我的示例中,我创建了几个函数(使用mathtikz 库),用于计算从 x 轴给定点到椭圆(圆也是椭圆)绘制的切线的交点坐标。然后我需要的只是泰勒斯截距定理(和 tikzcalc库),我得到了以下内容:

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{calc}
\usetikzlibrary{math}

\tikzmath%
{%
  function slope(\xp,\a,\k)
  {% slope of the tangent form the point (xp,0) to the ellipse x^2/a^2+b^2/k^2a^2=1
     return {\k*\a/sqrt(\xp*\xp-\a*\a)};
  };
  function interx(\xp,\a,\k)
  {% tangent point x (same tangent as above)
     \mm = slope(\xp,\a,\k);
     return {\mm*\mm*\xp/(\k*\k+\mm*\mm)};
  };
  function intery(\xp,\a,\k)
  {% tangent point y (same tangent again)
     return {slope(\xp,\a,\k)*(\xp-interx(\xp,\a,\k))};
  };
}

\begin{document}
\begin{tikzpicture}[line join=round]
% dimensions
\def\a {1}                   % cyan ellipse horizontal semi-axis
\def\k {2}                   % ratio between ellipses semi-axes, b/a
\def\xp{14}                  % point P, x coordinate (see below)
\def\re{0.75}                % ratio between yellow an cyan ellipses
\def\yc{0.75}                % ker circle center, y
\def\rc{0.5}                 % ker circle radius
\def\xc{4}                   % big circle center, x
% coordinates
\coordinate (P)  at (\xp,0); % point P where the ellipses tangents meet
\coordinate (A0) at (0,0);   % cyan ellipse, center
\coordinate (A1) at ({interx(\xp,\a,\k)},{ intery(\xp,\a,\k)}); % cyan ellipse, top tangent point
\coordinate (A2) at ({interx(\xp,\a,\k)},{-intery(\xp,\a,\k)}); % cyan ellipse, bottom tangent point
\coordinate (C0) at (0,-\yc); % ker circle center
\foreach\i in {0,1,2}
  \coordinate (B\i) at ($(A\i)!1-\re!(P)$); % yellow ellipse points B0, B1, B2 (same as A0, A1, A2)
\coordinate (D0) at ($(B0)-(0,\yc)$);       % 0
\coordinate (C1) at ({interx(\re*\xp,\rc,1)},{ intery(\re*\xp,\rc,1)-\yc}); % circle, top tangent point
\coordinate (C2) at ({interx(\re*\xp,\rc,1)},{-intery(\re*\xp,\rc,1)-\yc}); % circle, bottom tangent point
\coordinate (E0) at (\xc,0); % big circle center
% ellipses and circles
\draw[fill=cyan!40]   (A0) ellipse (\a cm and \a*\k cm)         node (G) [yshift=-2cm,below] {$G$};
\draw[fill=yellow!40] (B0) ellipse (\re*\a cm and \re*\a*\k cm) node [above] {$\mathrm{im}\,f$};
\draw[fill=green]     (C0) circle  (\rc)                        node {$\ker f$};
\draw                 (E0) circle  (\k*\a)                      node (H) [yshift=-2cm,below] {$H$};
% lines
\draw (A1) -- (B1);
\draw (A2) -- (B2);
\draw (C1) -- (D0) -- (C2);
\draw[-latex] (G)  -- (H) node [midway,below] {$f$};
\fill (D0) circle (1pt)   node [above]        {$0$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容