2

I am trying to draw a set theory image, I need to draw the lines like in this image: original image

I don't know how to specify the beginning and the end of the lines, so I get this result: LaTeX image

here is the my laTeX code:

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

Thank you.

Bernard
  • 271,350
Hind Dev
  • 641
  • See this: https://tex.stackexchange.com/questions/103727/how-to-draw-tangent-to-two-touching-circles-and-marking-the-points – hpekristiansen Jul 12 '21 at 16:22
  • actually, I tried the tangent function, but I've got an error saying that's it can't calculate it for an ellipse – Hind Dev Jul 12 '21 at 16:28
  • 1
    What about e.g. \draw (G.north) to (im.north);? – Torbjørn T. Jul 12 '21 at 16:31
  • @Torbjørn T Thank you, it works with north and south – Hind Dev Jul 12 '21 at 16:36
  • \draw (ker) +({atan(110pt/1.25cm)}: 1.25 ) -- (p); \draw (ker) +({-atan(110pt/1.25cm)}: 1.25 ) -- (p); – hpekristiansen Jul 12 '21 at 16:53
  • It is strange to mix positioning in pt and cm, unless there is some purpose. I would redo this figure in tkz-euclide - I am almost sure that it can do tangents of ellipses. – hpekristiansen Jul 12 '21 at 16:56
  • Here is a single tangent: https://tex.stackexchange.com/questions/599522/tangent-on-ellipse-in-a-point-with-tikz - but I do not know how to solve for a double ellipse tangent - except for calculating the coordinates. – hpekristiansen Jul 12 '21 at 17:06
  • Do you really need the comon tangents of two ellipses? If so, state it explicitly – Black Mild Jul 12 '21 at 17:58
  • Thanks, I just needed to draw the picture for a math tutorial. thank you all – Hind Dev Jul 12 '21 at 17:59
  • A "a math tutorial" does not tell us what you want/need. The reason you have not received any answers is because it is either very simply (but no one want to spend time drawing lines from random coordinates) OR very complicated with code you might not want/can not understand (but no one want to spend time doing it when that is maybe not what you want). – hpekristiansen Jul 12 '21 at 19:13

1 Answers1

3

This is not very difficult to draw in tikz. In my example I made a couple of functions (with math tikz library) that compute the coordinates of the intersection points of the tangent drawn from a x-axis given point to an ellipse (and a circle is an ellipse too). Then all I need is Thales' Intercept Theorem (and tikz calc library) and I get the following:

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

enter image description here

Juan Castaño
  • 28,426